google-cloud-functions

example for caching cloud function for firebase requests and only re cache after a successful edit to the profile

本秂侑毒 提交于 2020-01-13 19:24:10
问题 In my app, Users profiles are open to the public and only updated by the profile owner. The profile URL is example.com/profile?user=@user.me And based on the docs https://firebase.google.com/docs/hosting/functions. I can cache the response JSON of the function, in this case, the public profile. Which will save me a lot of at cloud functions executions and Firebase database bandwidth And when the user updates his profile, I want to re cache the profile in the CDN. I think that can be done by

Firebase cloud function exits with code 16 what is error code 16 and where can I find more info?

£可爱£侵袭症+ 提交于 2020-01-13 18:30:12
问题 one of my cloud functions on firebase exits with code 16 as an error. I tried to google and find out what that code is but no luck at all. Error: Process exited with code 16 at process.on.code (/srv/node_modules/@google-cloud/functions-framework/build/src/invoker.js:393:29) at process.emit (events.js:189:13) at process.EventEmitter.emit (domain.js:441:20) at process.exit (internal/process/per_thread.js:168:15) at logAndSendError (/srv/node_modules/@google-cloud/functions-framework/build/src

How to receive and parse email with Cloud Functions?

a 夏天 提交于 2020-01-13 16:27:30
问题 Google Cloud Functions allows you to easily activate a function upon a trigger (eg Firebase data change, HTTP request...). I am looking for a way to execute a function when a user sends (or typically replies) to a email address. For instance, my dashboard sends an email, I would like to catch the reply, parse the content and upload it to Firebase as a comment in my Dashboard. I understand that Google recommends to use Sendgrid. I however don't understand: - How to setup the trigger upon a

Import Firestore dependencies and types to node.js

…衆ロ難τιáo~ 提交于 2020-01-13 13:46:31
问题 I'm recently updating my cloud functions to TypeScript after the talks on the FirebaseSummit of this year. All my code looks quite cool, but I'm having some problems trying to recover the types of Firestore API, such QuerySnapshot , DocumentReference ... async function getEventsMadeByUser(userId: string): Promise<FirebaseFirestore.DocumentSnapshot[]> { const eventsMadeByUserQuery = await instance.collection('PrivateUserData') .doc(userId).collection(EVENTS) .where('interactionUser', '==',

Node/Firebase onCall asynchronous function return

你离开我真会死。 提交于 2020-01-13 10:39:07
问题 The user types a message into a chat client (a website). This message is sent through to a cloud function set up on firebase. The cloud function then queries a 3rd party API which returns a response. This response needs to be sent back to the client to be displayed. So basically my client calls a cloud function like so... var submitMessage = firebase.functions().httpsCallable('submitMessage'); submitMessage({message: userMessage}).thenfunction(result) { //Process result }); My cloud function

Cloud Functions - Cloud Firestore error: can't get serverTimestamp

て烟熏妆下的殇ゞ 提交于 2020-01-13 10:35:10
问题 Cloud Functions - Cloud Firestore error: can't get serverTimestamp const admin = require('firebase-admin'); exports.userlog = functions.firestore .document('user/{userId}') .onUpdate((change, context) => { const db = admin.firestore(); //var timestamp = db.FieldValue.serverTimestamp(); var timestamp = db.ServerValue.TIMESTAMP; ... return db.collection('userlog').add( { userId : previousValue.userId, ... timestamp: timestamp }).then(ref => { return console.log('Added document with ID: ', ref

Deleting a node from firebase database using firebase cloud functions

只愿长相守 提交于 2020-01-13 02:48:12
问题 I'm trying to make a firebase cloud function to delete a node from Firebase Database. The log messages show that the function executed "ok" but it doesn't seem to remove any element from the database. I wrote the function taking help from the accepted answer in How to delete data in Firebase? Here is the snippet of the code const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); //path is defined as the value

Generating a custom auth token with a cloud function for firebase using the new 1.0 SDK

拟墨画扇 提交于 2020-01-12 14:33:27
问题 As of firebase-admin@5.11.0 and firebase-functions@1.0.0 firebase-admin no longer takes in an application config when the app initializes. I had a firestore function that would generate a custom token using firebase-admin’s createCustomToken . Calling that function would generate a credential that I would pass into initializeApp in the credential attribute. How would I go about doing that now? Do I need to edit process.env.FIREBASE_CONFIG somehow and put the serialized credential there before

Generating a custom auth token with a cloud function for firebase using the new 1.0 SDK

我怕爱的太早我们不能终老 提交于 2020-01-12 14:32:21
问题 As of firebase-admin@5.11.0 and firebase-functions@1.0.0 firebase-admin no longer takes in an application config when the app initializes. I had a firestore function that would generate a custom token using firebase-admin’s createCustomToken . Calling that function would generate a credential that I would pass into initializeApp in the credential attribute. How would I go about doing that now? Do I need to edit process.env.FIREBASE_CONFIG somehow and put the serialized credential there before

Declare separate Firebase Cloud Functions and still use Express.js

做~自己de王妃 提交于 2020-01-12 03:40:06
问题 There are many examples of using Express for Firebase Cloud Functions. In every example of I have found the code exposes the Express app as a single Cloud Function: exports.app = functions.https.onRequest(app); For one's Firebase Project Functions that means they will see one entry called "app" and all logs for all Express.js HTTP listeners will go to one place in Firebase. This also means, no matter how large one's Express.js app is, Firebase will deploy a single function in production for