Firebase realtime database weird behavior - node.js

before this morning everything works perfectly with Firebase Realtime database. With my app, I retrieve nodes, update nodes through Firebase components. Since this moring, when I want to see Firebase realtime database on the console, it's blank, nothing to show like this. I already tried to refresh the page, to change for another brower, to log in/log out, it's always the same result :
The most weird is that for some users everything is fine but for others, they can't reach to authenticate on Firebase. They can't read new posts...
So, what's going on ?
There are no changes on the app code since 3 weeks and everyting was fine. The only thing is that a couple of days I received a message from Google Cloud Platform saying :
We’re contacting you because the Node.js project has informed Google that all current versions of v4.x to v8.x are vulnerable to an issue that can be used by an external attacker to cause a denial of service. This includes the current Google Cloud Functions (GCF) runtime Node.js 6.9.1. To mitigate this issue, Google will upgrade all functions to Node.js 6.11.1 on July 20th, 2017. We recommend you test your Cloud Functions with the new runtime version (Node.js 6.11.1) on July 17th.
Maybe that's the issue ? The update not finished well ? (Because I use Cloud functions for some data updates on the realtime database).

Related

What is the difference between making app using mongodart package and rest api in flutter

Hi I have recently started to make andriod app.At first i made it using firestore but as i started learning a bit more i realized as per as my requirement firestore would be costly so i shift to mongodb. The i came to know about mongodart package so i started building it using mongidart soon i realized that there are certain features missing in mingodart like the db.watch to monitor realime changes and also the data fetching time from mongodb is bit slow(I might be wrong as i am a new learner).
Now my question is will i be able to solve the problem like slow fetching the data from database also monitor realtime changes if i build it using rest api(NODE jS + Flutter + Mongodb).
Please help me out i need to deploy an app very soon.
Is there any difference between building a flutter app using mongodart package and restapi

How to call Oracle DB from Google Cloud Functions in Node.js

I'm trying to create a small Google Cloud Function (GCF) that will query Oracle DB and send email. I'm looking into using Node.js. I wasn't able to find anything useful, the only closes I found was a post regarding GCF to Oracle with Python. Please let me know if there is a way to call Oracle DB from GCF
In summary it's not possible because you need to install Instant Client and you can't on Cloud Function environment. Same issue with AppEngine Standard.
I'm writing an article on Medium on this. I'm waiting a bug fix on Cloud Run and the validation of Google (because some things can be confidential in it) before publishing it.
There is 2 workaround:
build a container (simply put an express server in front of your function, that's all!).
If you need to reach OnPrem Oracle DB you could deploy your container on AppEngine Flex (However don't scale to 0) and set up a serverless VPC Connector
If you don't need a serverless VPC connector, you will be able to deploy on Cloud Run in a couple of weeks, after the bug rollout
Use Java. You will have to download the Oracle Jar driver manually and to install it manually in Maven/Gradle, but then it work anywhere, even on AppEngine standard.
UPDATE
The bug with Cloud Run and GVisor has been solved. Here my article

confusions about firebase / cloud firestore

I been working on a React project using firebase auth and cloud firestore as the database and I been reading the official documents. But I am grappling with the idea of whether to use mobile/web SDKs and server client libraries and I am afraid I might have some misconceptions about Cloud Firestore Security Rules.
I read this page https://firebase.google.com/docs/firestore/client/libraries several times and it is about SDKs and client libraries for firestore. It seems to me that it suggests there are two ways of using firestore: one is through Mobile and web SDKs and one is through Server client libraries. And if I am using Mobile and web SDKs then my project would be classified as serverless since I am only building the front end and let Goole to handle the database and user authentication. The other way to use firestore, which is Server client libraries, it seems like it is meant to be used with your own server. It then refers to this as client libraries in the section, But the thing I don't quite understand is, what does client mean here? I'm sure it doesn't mean the same thing as in "the mobile and web SDKs support serverless app architectures where clients connect directly to your Cloud Firestore database.", where I assume a client is an end user who is browsing your website or web app. So what does this the client mean as in Server client libraries?
Since I am only able to build front end app or the client side app, I guess I should go with Mobile and web SDKs option to start using the firebase. Here comes the second question, when selecting a starting mode for my Cloud Firestore Security Rules, there are two modes: Test mode
and Locked mode. For Test mode, it says "Good for getting started with the mobile and web client libraries, but allows anyone to read and overwrite your data. After testing, make sure to review the Secure your data section.". My first confusion is, does client libraries refer to the Server client libraries previously I mentioned? If so, as a serverless project without a server I cannot technically I cannot choose this mode? Then for Locked mode it says, "Denies all reads and writes from mobile and web clients. Your authenticated application servers (C#, Go, Java, Node.js, PHP, Python, or Ruby) can still access your database." Again this option seems like it is not for me since it mentioned Your authenticated application servers, and for my project I don't have a server, or the server is on the google cloud platform. So can someone please correct me if I am understanding this wrong. Also, if I opt-in the Test mode, I suppose it allows anyone to read and overwrite my data. But I feel like there needs more explanation on the word anyone here. I think at least the person needs to have the exact firebase configuration as my project has. something like this
const config = {
apiKey: "myapikey",
authDomain: "my-auth-domain.firebaseapp.com",
databaseURL: "my-db-url.com",
projectId: "my-pid",
storageBucket: "my-storage-bucket",
messagingSenderId: "my-sender-id",
};
to access my database. I think by anyone, here it means anyone with this config file and doesn't need to log in to my project in order to mess with my database. This is my understanding, can someone please correct me? Finally, in my case, I just want that anyone who can log in to my project can have access to the database(both read and write). Which mode(test or locked) should I go with? Or I need more configuration for this?
Is it true that whether I choose web SDKs or Server client libraries to start my firestore project, I all need to use firebase-admin? But do I need to use Firebase CLI to init my project as a firebase project with the automatically generated firebase.json?
The official documents constantly use the word web and node.js, such as this image. . I actually don't know what they exactly mean. If I am writing React, should I go with web or node.js? If it belongs to web, I am importing stuff like import firebase from "firebase/app"; in my react project, these are also modules for Node.js. Again I am confused here.
I know this might be too long to read and the questions might be a bit trivial but I really appreciate if someone could clear up my confusion about firebase.
As far as I know, Here are the answers to your questions:
1) So what does this the client mean as in Server client libraries?
Server client libraries are used to access Firebase from servers which run on Java, Python, Go etc.
2) Which mode(test or locked) should I go with? Or I need more
configuration for this?
Test mode opens your database to the public which means any user can access your database without authenication.
Locked mode keeps your database locked down by default. You can then add rules to grant access to certain read or writes.
I would recommend to start out the project with this and later configure firestore security rules to open up access to your database according to your application's requirements. You can find references here : https://fireship.io/snippets/firestore-rules-recipes/
3) Is it true that whether I choose web SDKs or Server client libraries
to start my firestore project, I need to use firebase-admin? But do I
need to use Firebase CLI to init my project as a firebase project with
the automatically generated firebase.json?
firebase-admin available on npm is the Firebase Admin Node.js SDK to access your firebase database with admin privileges. This can be useful when you initialize/access the application specific configurations and parameters in your database.
You don't need Firebase command-line to initialize your firebase project and generate the firebase config file. You can access it through Firebase console of your project once you create your project in firebase. Reference : https://support.google.com/firebase/answer/7015592?hl=en
4) If I am writing React, should I go with web or node.js?
You should go with Web because node.js SDK is used for access to your Firebase services from privileged environments (such as servers or cloud) in Node.js.
Reference: https://www.npmjs.com/package/firebase
Additional Point: Found this for React in the Google's documentation for FIrebase SDKs. https://github.com/tylermcginnis/re-base
Hope its clearer now.

Rolling back to an older version of a firebase function (google cloud function)

I am trying to find an easy way to roll back to a/the previous version of my firebase function(google cloud function), in case the new release of this firebase function creates a problem to the deployed system.
The way I deploy the functions is via firebase cli (firebase deploy --only functions) and not gcloud cli.
Is there an easy way to roll back to the previous version of the function?
There is currently no rollback feature. You will have to deploy the function again using the source code that you want to have in its place. To make this easier on themselves, developers typically tag their code in source control after a deploy, so that it's easy to check out a specific version of the code to roll back later.

programmatically create users in firebase node

With the latest node SDK, I'm unable to programmatically create users as I had done with older versions of firebase. I need this in order to create a pre-populated database for testing purposes. The node SDK does not support createUserWithEmailAndPassword. Any idea how to programmatically create users or get the uids of users from the db or programmtically sign in as a user with the web client's signinWithEmailAndPassword?
Are you doing your testing with a live firebase instance? It might be better to use firebase-server to do this type of testing: https://firebase.googleblog.com/2015/04/end-to-end-testing-with-firebase-server_16.html
This should make your tests run faster and you won't be reliant on an internet connection.
Most of the client-side auth and user management methods (including creating users) are available in the Node.js environment since the 3.3.0 release of the Firebase JavaScript SDK. The SDK should now be mostly isomorphic, but see my message on another thread here for the full details. Full release notes for that release are here.

Resources