firebase-cloud-functions

Cloud Functions for Firebase HTTP Request

一笑奈何 提交于 2019-12-30 13:56:22
问题 I want to send an HTTP Request from Android to a cloud function, post some values, then input these values into real time database. index.js const functions = require('firebase-functions'); exports.testPost = functions.https.onRequest((req, res) => { console.log(req.body); }); How can I accomplish this? 回答1: I see three steps in here: Calling a Cloud Function from Android . This is the same as calling any other HTTP URL from Android. See Calling a Cloud Function from Android through Firebase

Storing Image Using Cloud Functions for Firebase

北慕城南 提交于 2019-12-23 18:10:20
问题 I'm trying to refactor some code to use Cloud Functions for Firebase. The code should store an image at a path in Firebase storage. For the most part the code is the exact same as before except now instead of server.post('/', (req, res) => { // Some code } I'm using the following according to the Firebase documentation exports.getProcessedImage = functions.https.onRequest((req, res) => { // Some code }); The code worked previously but now I'm having trouble getting my test image to save to

How to make an HTTP request in Cloud Functions for Firebase?

社会主义新天地 提交于 2019-12-21 06:48:38
问题 I am trying to make a call to apples receipt verification server using Cloud Functions for Firebase. Any idea how to make an HTTP call? 回答1: Keep in mind that your dependency footprint will affect deployment and cold-start times. Here's how I use https.get() and functions.config() to ping other functions-backed endpoints. You can use the same approach when calling 3rd party services as well. const functions = require('firebase-functions'); const https = require('https'); const info =

Organize Cloud Functions for Firebase

家住魔仙堡 提交于 2019-12-05 09:56:35
问题 What is the best practice to organize all our Cloud Functions for Firebase? I see from the sample GitHub repository that all functions reside in a single index.js file. I guess for bigger project that there is a better approach to organize Cloud Functions for Firebase in different files/directory. 回答1: I organize my event handlers by provider and resource in a folder called triggers . E.g. where auth is the provider and user is the resource; the folder functions/triggers/auth/user contains an

Organize Cloud Functions for Firebase

两盒软妹~` 提交于 2019-12-03 22:27:25
What is the best practice to organize all our Cloud Functions for Firebase? I see from the sample GitHub repository that all functions reside in a single index.js file. I guess for bigger project that there is a better approach to organize Cloud Functions for Firebase in different files/directory. I organize my event handlers by provider and resource in a folder called triggers . E.g. where auth is the provider and user is the resource; the folder functions/triggers/auth/user contains an onCreate.js and onDelete.js , which welcomes and cleans up a user respectively. +--/auth | +--/user | +--

Cloud Functions for Firebase HTTP Request

女生的网名这么多〃 提交于 2019-12-01 13:19:02
I want to send an HTTP Request from Android to a cloud function, post some values, then input these values into real time database. index.js const functions = require('firebase-functions'); exports.testPost = functions.https.onRequest((req, res) => { console.log(req.body); }); How can I accomplish this? I see three steps in here: Calling a Cloud Function from Android . This is the same as calling any other HTTP URL from Android. See Calling a Cloud Function from Android through Firebase Parsing parameters from the call in your Cloud Function A HTTP triggered Cloud Function is really just an

How can I use nodemailer with Cloud Functions for Firebase?

别来无恙 提交于 2019-11-28 11:43:42
I'm trying to use nodemailer in a Cloud Functions for Firebase but keep getting errors seeming to be that the smpt server cant be reached or found. Iv'e tried gmail, outlook and a normal hosted smpt service. It works well from my local node server. This is the logged error I receive from the failed attempt to send email: { Error: getaddrinfoENOTFOUNDsmtp-mail.outlook.comsmtp-mail.outlook.com: 587aterrnoException(dns.js: 28: 10)atGetAddrInfoReqWrap.onlookup[ asoncomplete ](dns.js: 76: 26)code: 'ECONNECTION', errno: 'ENOTFOUND', syscall: 'getaddrinfo', hostname: 'smtp-mail.outlook.com', host:

Access db data in Cloud Functions for Firebase

我只是一个虾纸丫 提交于 2019-11-27 14:47:10
In Cloud Functions for Firebase, for example: exports.makeUppercase = functions.database.ref('/messages/{pushId}/original') .onWrite(event => { //how to access data at another node, for example //important/messages/{pushId} }) How to do I read data at another node, for example /important/messages/{pushId} ? Thanks Incinerator const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.makeUppercase = functions.database.ref('/messages/{pushId}/original') .onWrite(event => { const getSomethingPromise = admin

How can I use nodemailer with Cloud Functions for Firebase?

我与影子孤独终老i 提交于 2019-11-27 06:22:29
问题 I'm trying to use nodemailer in a Cloud Functions for Firebase but keep getting errors seeming to be that the smpt server cant be reached or found. Iv'e tried gmail, outlook and a normal hosted smpt service. It works well from my local node server. This is the logged error I receive from the failed attempt to send email: { Error: getaddrinfoENOTFOUNDsmtp-mail.outlook.comsmtp-mail.outlook.com: 587aterrnoException(dns.js: 28: 10)atGetAddrInfoReqWrap.onlookup[ asoncomplete ](dns.js: 76: 26)code:

Access db data in Cloud Functions for Firebase

我的梦境 提交于 2019-11-26 16:53:46
问题 In Cloud Functions for Firebase, for example: exports.makeUppercase = functions.database.ref('/messages/{pushId}/original') .onWrite(event => { //how to access data at another node, for example //important/messages/{pushId} }) How to do I read data at another node, for example /important/messages/{pushId} ? Thanks 回答1: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.makeUppercase = functions