question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firebase functions implementation

See original GitHub issue

Hi Sean,

I want to start off by saying again how much I love this project and the simplicity of it, it just makes working on API’s so much easier, structured, predictable and consistent.

Now, for multiple reasons, I decided to stop building these live server apps and switched completely to the functions-based approach, more specifically firebase. Now coding these functions, even though it supports typescript out of the box, is a complete pain. There’s no decent support for middleware, wrapping functions, it is indeed possible to manually add middleware and use some express features but that isn’t a thing for callable functions.

Now I’d like to start working on something similar to overnightjs but for functions, at first, for firebase functions specifically.

The baseline concept is you’d have your controllers + child controllers and your basic decorators are @OnRequest and @OnCall in every class. The basic features to support would be middleware + wrappers for @OnRequest(<NAME>) and just wrappers for @OnCall(<NAME>).

Now because these would be functions operating independently from each other, we’d also want to have some decorator for things to be initialized only for the function, for example, a mongoose db connection, which you wouldn’t necessarily want to configure globally for all your stuff, maybe this could be solved with the standard @Wrapper?

In index.ts you’d configure your global middleware + global async wrappers for '@OnCall and '@OnRequest;

Now for the end result, let’s assume we have a controller called ‘Reports’ which has a child controller called ‘Jobs’ which has a function called ‘daily’; Your end function name would be a camelCase of that tree, such as: reportsJobsDaily;

I was thinking instead of just making my own thing, I’d suggest we build it together as part of the @overnight project?

Let me know what you think, thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sebastiangugcommented, Jul 24, 2019

@Nefiron there’s no way to implement overnightjs into something like cloud functions due to their nature, unless you make your whole API 1 cloud function which I have some doubts on how efficient it might be/how it would work.

I have just published minutes ago a super-beta version of the ‘mini-framework’/helpers (idk what to call the thing really) I’m working on to write firebase functions in a more structured way. check the folder ‘sample-project’ – it should be quite good to get you started but if you have any questions feel free to post them in that repo and I’ll do my best to help.

If you want to contribute and grow the thing, let me know and I’ll add you to the team, good luck!

Link: https://github.com/decorfn/firebase

0reactions
sebastiangugcommented, Jul 30, 2019

@Nefiron I know of the thing, of course, and easy scalability is always the strong point of Cloud Functions. But when it comes to actual performance, I haven’t actually ran any tests to compare things with a traditional server + express app and how that performance compares as you scale.

Until I do those tests, I’ll use common sense and assume that it performs decently once a function is ‘woke’, but there’s got to be some hard data aspect to back these assumptions up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloud Functions for Firebase - Google
Cloud Functions for Firebase is a serverless framework that lets you automatically run backend code in response to events triggered by Firebase features...
Read more >
Google Cloud Functions and Firebase
Firebase gives mobile developers access to a complete range of fully managed mobile-centric services including analytics, authentication and Realtime Database.
Read more >
Introduction To Firebase Cloud Functions - Medium
Recently Google's Firebase introduces a new functionality which is called Cloud Functions. With this new service Firebase offers a scaleable ...
Read more >
Cloud Functions for Firebase Sample Library - GitHub
Cloud Functions is a hosted, private, and scalable Node.js environment where you can run JavaScript code. Cloud Functions for Firebase integrates the Firebase...
Read more >
Cloud Functions for Firebase - FlutterFire
Cloud Functions for Firebase let you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found