Lets talk about the Backend setup! #7
Replies: 3 comments 9 replies
-
My thoughts on simplification.This is currently how I have my import * as admin from "firebase-admin";
// Triggers
import { userCreated } from "./triggers/algolia-user-index";
// APIs
import acceptUsersAppointment from "./api/accept-users-appointment";
admin.initializeApp();
// Triggers
exports.userCreated = userCreated;
// APIs
exports.acceptUsersAppointment = acceptUsersAppointment; Also why use express directly? Firebase functions is using express underneath.
const myFunction = functions.https.onCall(async (data, context) => {
if (!(context.auth && context.auth.token)) throw Errors.NOT_AUTHENTICATED;
...
});
|
Beta Was this translation helpful? Give feedback.
-
Just in case anyone didn't notice this. |
Beta Was this translation helpful? Give feedback.
-
I like this solution you have come up with here, I think it is straightforward and as you said, it will scale well. Though it might be a bit over-engineered as even with a codebase with a lot of functions keeping the index.ts file tidy is a trivial task. And there is something to be said for explicit action over implicit consequences. But we are engineers so it is natural to engineer a solution to potential problems =) Where I think this can really shine is with handling versioning of firebase functions as I feel that is a major pain point right now in the firebase ecosystem. So I would do something like structure the folder like orders
And extend the export helper to append the version number to the function names. This way you can adapt and grow your backend while keeping backward compatibility. Also, any particular reason you went with idle instead of restful? Restful is an industry-standard term |
Beta Was this translation helpful? Give feedback.
-
The backend setup has been decided and implemented! I'd like to keep this discussion alive to talk about better implementations or changes in the code that could benefit us as the backend maintainers. To see the overview of the current state of the backend you can go to this readme.
One thing that has been brought up is:
My answer to this good question:
So this discussion is to help this series with some insights from more experienced typescript developers. Lets get talking!
Beta Was this translation helpful? Give feedback.
All reactions