I am parse.com user, and now I look for another service. How can I write back end logic to firebase?
let say I want to validate all the values on server side, or trigger things. I thought about one solution, but I want to know the recommended way.
I think to
their something simpler? In parse I used cloud code, I want that the logic will not be on the client side but on a server side.
Firebase is a Backend-as-a-Service (BaaS) app development platform that provides hosted backend services such as a realtime database, cloud storage, authentication, crash reporting, machine learning, remote configuration, and hosting for your static files.
Firebase provides the best back-end server, great database and analytics solution, and useful integrations with other Google products. Most of all, users like that it's free to use and has affordable subscription options. A wisely designed backend solution guarantees project scalability and data security.
Firebase provides a ready-made backend system that frontend developer can use to hook their GUI without waiting for the backend to be ready.
Firebase is a fully managed backend service that gives you best-in-class infrastructure for your web apps, handling everything from user authentication and server scaling, right through to crash analytics and a reliable testing environment. Just set it and forget it.
Update (March 10, 2017): While the architecture I outline below is still valid and can be used to combine Firebase with any existing infrastructure, Firebase just released Cloud Functions for Firebase, which allows you to run JavaScript functions on Google's servers in response to Firebase events (such as database changes, users signing in and much more).
The common architectures of Firebase applications are pretty well-defined in this blog post Where does Firebase fit in your app?.
The architecture you propose is closest to architecture 3, where your client-side code talks both directly to Firebase and to your node.js server directly.
I also highly recommend that you consider option 2, where all interaction between clients and server runs through Firebase. A great example of this type of architecture is the Flashlight search integration. Clients write their search queries into the Firebase database. The server listens for such requests, executes the query and writes the response back to the database. The client waits for that response.
A simple outline for this server could be:
var ref = new Firebase('https://yours.firebaseio.com/searches'); ref.child('requests').on('child_added', function(requestSnapshot) { // TODO: execute your operation for the request var responseRef = ref.child('responses').child(requestSnapshot.key()); responseRef.set(result, function(error) { if (!error) { // remove the request, since we've handled it requestSnapshot.ref().remove(); } }); })
With this last approach the client never directly talks to your server, which removes all kind of potential problems that you have to worry about. For this reason I sometimes refer to them as "bots", instead of servers.
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