This question already has an answer here:
How can I rent and use my own servers for cloud functions? [closed]
(1 answer)
Closed 1 year ago.
The cloud function in firebase needs you to enable the billing plan.
Can I use cloud functions on my own Nodejs server and access the events by installing npm install firebase-functions without enable cloud functions on firebase?
No. You can only use the Firebase Functions Emulator to test your functions locally (you cannot deploy to Firebase unless you enable billing). Self-hosting a server is different and using server-less Cloud functions and may not be as easy to scale like Cloud functions do.
The events (like Firestore triggers) that you are referring to can be used to trigger Cloud functions only. If you host your server on your server then it'll be best to route all the operations through it. For example, if you wanted to trigger a function when a new document is added to Firestore, instead of creating the document directly from client make a request to your server and add the document using Admin SDK and process anything else at the same time.
Related
This question already has answers here:
Locking down Firebase DB access to specific apps
(2 answers)
Closed 3 months ago.
I have two apps registered in Firebase, say App A and App B. I haven't setup any firebase authentication system but I want to allow requests only from App A and App B. I want to check if the request is coming from my apps and then only perform the actions. If the request is from somewhere else then just reject it.
I want to have this security for Cloud Firestore and Firebase Storage.
Currently, this feature isn't available, some of this will be rolling out in the near future using the new App Check: https://firebase.google.com/docs/app-check
At this time, App check only supports:
Realtime Database
Cloud Storage
Cloud Functions (callable functions)
I'd like to implement a full text search an app that is using Cloud Firestore.
Integrating with Algolia sounds great, but it can't work on the free Spark plan since outbound networking is limited to Google services only.
Therefore, the obvious question:
(1) Is it possible to use firebase-functions to create a function that monitors Firestore changes and deploy it to something like Zeit's Lambda or AWS Lambda?
Somewhat related question:
(2) Is it possible to use onSnapshot instead of onCreate/onUpdate/etc. to monitor Firestore changes?
You can't deploy Cloud Functions code to other serverless function providers. You can certainly try to reuse your core logic, but each provider has its own APIs and infrastructure, and firebase-functions only knows how to work with Cloud Functions.
I am new on firebase cloud functions. I would like to ask a question about always running or self-triggering functions. How can we handle these things? How can we implement always running functions or self-triggering?
Google Cloud Functions are snippets of code that run in response to events that happen somewhere else. Some example events:
a HTTPS URL is accessed, either from application code, or in some other way
a User account is created on Firebase Authentication
a node is written in the Firebase Realtime Database
a message is sent to a Cloud PubSub topic
There is no concept on a forever-running function on Cloud Functions (nor on other, similar Functions-as-a-Service offerings), although it's definitely possible to create a function that gets triggered every minute or so (like a cron job).
I want to read and write data in database real time across cloud functions but I don't know if this is possible, also I don't know if this is good practice or if is better make this through with SDK database realtime
I learning firebase and react native, I am new learning these topics.
From the docs:
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
Cloud Functions runs Node v.6.11.5, so we recommend that you develop locally with this version.
You are able to use realtime database trigggers like onCreate(), onWrite(). Also you are able to use set() to send data to the realtime database.
https://firebase.google.com/docs/functions/
https://firebase.google.com/docs/functions/database-events
In times when Parse.com was on they had a function that called a cloud function directly and returned whatever I wanted. So I could have all the server logic on the server, not in client code. Doe's Firebase has it as well? I can't find it - all I found are HTTP triggers, but it implies that it's not available through Javascript SDK. Am I missing something or do I have to use REST interface for that?
To run server-side code that is triggered by events in Firebase, you'd use Cloud Functions for Firebase. Currently these can trigger code through the Firebase Database updates, Authentication, Analytics, Cloud Storage and HTTP. The documentation I linked has all the details.
As Frank van Puffelen has explained you could use Functions, I'll like to add a couple of things.
You could also use the Firebase Database Admin SDK for the Database, this requires you have a server
Firebase Functions is a sort of big brother, constantly listening for whatever you want. Currently starting and deploying functions is fairly easy and fast, I love this how to video. Basically, you have to install the CLI and then using commands, create a project, write your js for Functions and for deploying those changes to Firebase Functions use the CLI again
Functions can listen more than what the Admin SDK can, the Admin SDK is for the Database while Functions is for, authentification, database, and cloud messaging. This means any user registration or deletion or any change in a node, can trigger further logic. This logic could include sending push notifications. There is a github repo where you can see a lot of examples, I made myself a small repo for the same purpose