I have a function where I want to perform some server-side validations, but I"m not sure how to do this? Any suggestions where I should look. THere is nothing in the documentation of how to do it?
The server side of Firebase Cloud Messaging consists of two components: The FCM backend provided by Google. Your app server or other trusted server environment where your server logic runs, such as Cloud Functions for Firebase or other cloud environments managed by Google.
In short, Firebase is a platform that allows you to build web and mobile applications without a server-side programming language.
The best way to do this is to create a "pending" node and a "completed" node in Firebase. Every time the client takes an action that requires server validation, have the client add an entry into the pending node. On the server side, you can use the Firebase node.js client (or Java SDK) to listen for changes on the "pending" node, validate the action, and then put it in the "complete" node if the validation succeeds. You'll need to setup your security rules such that only the server code can add items into the "complete" node (for example, by using the secret) - learn more about the Firebase security rules here: https://www.firebase.com/docs/security/security-rules.html
If your validations are fairly simple to perform, you may be able to do the validation using the security rules themselves - they provide simple string/integer/boolean validation.
It's late. However, just for someone passing by. Firebase has introduce Cloud Function
a month ago. Try to check the official link out. It allow you to put some logics in server side.
https://firebase.google.com/docs/functions/
In my understanding instead of thinking about the communication to server as common Request
and Response
you need to see it as Database trigger event
.
You can set up the function that will be called when specific action happen.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With