Flexibility for shared client/admin code? #4383
Replies: 3 comments 2 replies
-
Thanks for the thoughts! I have a few thoughts here as well. I have a personal project where I use Firestore in my JS frontend and my Node.js backend and I definitely duplicate a lot of helpers! But I am not one of the decision-makers for Admin SDK or Web SDK things so take my thoughts with a grain of salt:
|
Beta Was this translation helpful? Give feedback.
-
I work on Typesaurus, a universal Firestore ODM that allows using the same code in web and Node.js (and even React Native): https://github.com/kossnocorp/typesaurus Once the new Firebase SDK is generally available (or even earlier), I'll use the new SDK. |
Beta Was this translation helpful? Give feedback.
-
Just wanted to make comment on sharing of code. The sharing of types/interfaces between the client-sdk and admin-sdk, would provide the ability to code share. Currently FieldValue is different between both version, as well as converters interface. |
Beta Was this translation helpful? Give feedback.
-
Im sure a lot of this will be me getting ahead of myself, but I figured it'd be worth sharing? After looking through the docs a bit, something popped into my head.
One of the things that the new modular approach to Firebase might allow for is true client/admin code sharing, no?
For instance, in my app I allow users to manipulate documents (adhering to Firestore rules), but I also manipulate those same docs in Cloud Functions (where I want to ignore rules).
Even though these are different environments, the documents and the logic behind the manipulation are the same (get doc A, update field X, Y, and Z), BUT with the current admin/client it's extremely difficult (impossible?) to write cross-environment code. I find myself maintaining similar helper functions for both places
BUT, with the new modular approach, interacting with Firestore (seemingly) looks to be abstracted away from the app? So it seems like in the future we could be at a point where we can do something like...
Being able to abstract out business logic like this into modules could really open up the ability for people to build tools on top of Firebase that makes it even easier to get up and running with things.
I could see a world where full firebase-plugins can be created? Imagine something like...
Have something handle the logistics of collections, sub-collections, document data structure, etc. and you just get a nice exposed API to use. Sort of like how Firebase Extensions work but more modular?
Idk, like I said I'm sure I'm getting far ahead of myself and I'm not even sure if this is the right place to discuss this sort of thing, but it sure would be cool if stuff like this becomes a possibility due to the flexibility of the rewrite. If it's already possible to do something like this I would LOVE some resources cause I've tried and (in TypeScript at least), it seems like the client-sdk and the admin-sdk are too different to have any sort of abstracted logic module.
Looking forward to all the great work you guys are doing and excited to play around with the new alpha stuff!
Beta Was this translation helpful? Give feedback.
All reactions