google-cloud-functions

Firebase cloud function onUpdate child of list (NodeJs)

巧了我就是萌 提交于 2021-01-29 20:29:51
问题 How to trigger the firebase cloud function onUpdate each time any of the child "order_status" is == "accepted" (included the old Childs on trigger) my code won't work Have a look please : Code: exports.checkOrderStatus = functions.database.ref("/RestaurantOrders").onUpdate(async (change, context) => { var orderStatus = change.after.val().order_status; if (orderStatus == "accepted") { code... } else { return } } 回答1: exports.checkOrderStatus = functions.database.ref("/RestaurantOrders/{pushId}

How to continue running Firebase Cloud Function after request is finished

﹥>﹥吖頭↗ 提交于 2021-01-29 20:02:02
问题 Really bizzare that Firebase doesn't seem to work quite like typical Express app. Whatever I write in Express and copy-paste to Firebase Functions I typically get error. There is one that I can't figure out on my own though. This endpoint is designed to start a function and live long enough to finish even longer task. That request is a webhook (send docs, we will transform them and ping you when it's done to specified another webhook). Very simplified example below: router.post('/', (req, res

Triggering a cloud function from google sheets (via google apps script)

被刻印的时光 ゝ 提交于 2021-01-29 19:58:18
问题 I have been trying (with little success) to have a google cloud function be triggered via an http request from a google sheet (google apps script) and it seemingly won't work. A few important things: The function should only run if the user comes from my organization The user should not have to be invited to the GCP project I know this can be done very easily in google colabs and Python. The following script will let a user in my organization who is not in the GCP project trigger the cloud

Firebase Cloud Function to delete user

让人想犯罪 __ 提交于 2021-01-29 18:26:11
问题 We have a cloud function in my index.js: const functions = require('firebase-functions'); const firebase_tools = require('firebase-tools'); const admin = require('firebase-admin'); admin.initializeApp(); exports.deleteUser = functions.https.onCall((request, response) => { const userId = request.params.userId; console.log('deleting user: ' + userId + ' ...'); return firebase_tools.firestore .delete('messages/' + userId, { project: process.env.GCLOUD_PROJECT, recursive: true, yes: true, token:

How firebase http function to return snapshot to swift app

☆樱花仙子☆ 提交于 2021-01-29 15:26:42
问题 I have a firebase function performing a query and filtering by a geohash search radius. It's working but I am returning Json and what I really want to do is return a snapshot. I am new to firebase functions. Here is my firebase function var GeoFirestore = require('geofirestore').GeoFirestore; exports.geoQueryWitningRadius = functions.https.onRequest(async (req, res) => { const data = req.body; const lat = data.lat; const lon = data.lon; const radius = data.radius; const firestore = admin

How to cancel a scheduled firebase function?

余生长醉 提交于 2021-01-29 14:09:46
问题 I'm developing a NodeJS application, running on Firebase, where I need to schedule some email sendings, for which I intend to use functions.pubsub.schedule. Turns out that I need to cancel those jobs when needed, and I'd like to know some way to identify them for eventual possible cancellation, and some way yo effectively cancel them. Any way to do this? Thanx in advance 回答1: When you create a Cloud Function with something like this: exports.scheduledFunction = functions.pubsub.schedule(

Firebase database access denied with permission set

我与影子孤独终老i 提交于 2021-01-29 13:45:14
问题 I have carefully looked at other answers to similar questions and as far as I can tell everything is set correctly but still access is denied. Minimum working example: My Firebase Live Database Security Rule for the path 'user/{uid}' is as follows "rules": { "user": { "$uid": { ".read": "auth.uid === $uid", ".write": "auth.uid === $uid && !data.exists() " } } } in the typescript I attempt to read 'user/{uid}' for some user. //Firebase and firebase-fcuntions import const firebase = require(

Jest mock not resolving to each injected value

☆樱花仙子☆ 提交于 2021-01-29 13:39:51
问题 I'm trying to test a Firebase cloud function named myCloudFn in my functions/send.js module. My tests are in functions/test/send.spec.js : // send.js const admin = require('firebase-admin'); async function myCloudFn (email) { const authUser = await admin.auth().getUserByEmail(email); return authUser; } module.exports = { myCloudFn }; // send.spec.js const send = require('../send.js'); jest.mock('firebase-admin', () => ({ auth: () => ({ getUserByEmail: jest.fn() .mockResolvedValueOnce({ uid:

HTTP trigger Cloud Function in Flutter web

人走茶凉 提交于 2021-01-29 13:08:00
问题 I am trying to call a HTTP trigger Cloud Function from Flutter . I keep getting errors in the console while passing the parameters to the function. final HttpsCallable callable = CloudFunctions.instance.getHttpsCallable( functionName: 'hello_world', ); final HttpsCallableResult result = await callable.call( <String, dynamic>{ 'message': 'hello world!', }, ); Can someone point out what is it that I am doing wrong. The Cloud function used is def hello_world(request): request_json = request.get

Value of firebase functions onwrite sometimes is null

房东的猫 提交于 2021-01-29 12:54:24
问题 I'm trying to implement an Android ordering system and I'm using Realtime Database. To send notifications I'm using Firebase Functions in JavaScript. Each user is stored in the database along with their id, token to send the notification, among other data. What I'm trying to do is detect when a user receives an order and send them a notification . The problem appears here. In some cases the notification is sent and in others it is not . Viewing the logs of my "sendNotif" function I see that