google-cloud-functions

What is the correct way to split firebase cloud functions into different files?

我怕爱的太早我们不能终老 提交于 2021-01-28 09:50:52
问题 I'm trying to split a large cloud function into a smaller more maintainable files. However when deploying I always get the same error: Error occurred while parsing your function triggers. /Users/Raphi/Documents/Programing/Development/merchantAPI/functions/index.js:2 import { DirectPost } from '../functions/merchantPost'; ^^^^^^ SyntaxError: Cannot use import statement outside a module I spent most of last night googling but there doesn't seem to be any documentation for this simplified index

Write to firebase database from cloud function triggered by PubSub

蓝咒 提交于 2021-01-28 09:44:23
问题 I'm trying to use a daily trigger to alter information in my Firebase database. I have a number of other cloud functions that work properly, but I can't seem to get this function to alter the database. const admin = require('firebase-admin'); exports.daily_job = functions.pubsub.topic('daily-tick').onPublish((event) => { console.log("This job is run every day!"); const databaseRef = admin.database().ref('/accountActions/dailyDeletion'); databaseRef.child('delete').set("Data has been deleted!"

Firebase cloud functions find nearby locations

别来无恙 提交于 2021-01-28 09:40:59
问题 I need to find nearby vehicles within a specific radius to a given point and have those sorted by the distance from the given point. Does firebase provide a way to query geographical data? I need to do this within a cloud function. Entirely new to firebase so any help is appreciated. 回答1: Using the geofire library you could do something like this... exports.cloudFuncion = functions.https.onRequest((request, response) => { // logic to parse out coordinates const results = []; const

What is the best way to show reports with firebase?

穿精又带淫゛_ 提交于 2021-01-28 07:54:06
问题 I am currently using Cloud Functions to do aggregation in Firebase so that whenever a certain type of data entry occurs, I aggregate it accordingly and store it to show our reports. There are following concerns with this approach:- Adding new reports would mean going over all the existing data and that could be expensive with firebase realtime database Making any changes to existing reports is also non-trivial I was considering a solution like Cloud Dataflow. However, one issue is that it is

How to update or set property of firestore document after .onCreate cloud function trigger

家住魔仙堡 提交于 2021-01-28 07:34:33
问题 I'm currently trying to integrate Stripe with my Firebase's Cloud Firestore db through using Cloud Functions for Firebase. The onCreate trigger is happening correctly but I also want it to update or set a specific field called "customer_id" into the right document in my Users collection. I think something is a little off about how I write my function since I'm not the most experienced with javascript. I've also tried return admin.firestore().ref(`Users/${user.uid}/customer_id`).set(customer

Firebase Cloud functions to Android application notifications

戏子无情 提交于 2021-01-28 06:27:26
问题 I need some hints for the following system: client app: Android backend: Firebase Cloud Funtions database: realtime database One of the scenarios is as follows: All users are on android devices. Users are sign-in via OAuth2 (google accounts). User1 creates an offer and the offer is 'waiting' in active offers list. Other users are notified for the change is active offers list.. User2 requests the offer and the offer is 'requested' Other users are notified for the change is active offers list..

How to set using node engine version 10 in dialogflow inline fulfilment package.json?

萝らか妹 提交于 2021-01-28 06:05:14
问题 How to set using node engine version 10 in dialogflow inline fulfilment package.json? I try to set it in package.json "engines": { "node": "10" } But in my Firebase project, deployed fulfilment cloud function remains use 'Node.js 8'. 回答1: As of a few days ago, the Dialogflow inline fulfillment uses Node 10 (and you cannot switch back to Node 8). The downside of this is that you must have billing enabled for the GCP project your dialogflow agent is associated with, as under-the-hood the inline

Firebase Functions: Could not load default credentials

青春壹個敷衍的年華 提交于 2021-01-28 05:24:05
问题 I have a Firebase Function that subscribes to a Cloud PubSub topic. App is initialized very simply like this: import * as admin from 'firebase-admin'; admin.initializeApp(); I'm getting this error: "Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information. at GoogleAuth.getApplicationDefaultAsync (/srv/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:161:19) at process._tickCallback

Calling Cloud Function from Swift with JSON data

混江龙づ霸主 提交于 2021-01-28 05:20:49
问题 I have a Cloud Function hosted on Firebase that I am trying to call from a Swift app. It works fine when I call it from command line with the following script, however there is some issue with parsing the JSON data when I call it from swift. Command Line (works perfectly) time curl -v -X POST -d '{"url":"https://cdn.bmstores.co.uk/images/hpcProductImage/imgFull/303441-Volvic-6x500ml-Naural-Mineral-Water1.jpg"}' -H "Content-type: application/json" https://us-central1-themagicfactory-5cf7a

firebase batch updates and onWrite trigger synchronisation

送分小仙女□ 提交于 2021-01-28 04:41:16
问题 I have an issue with synchronizing two Firebase cloud functions, the first one performing a batch update on multiple documents and the second one triggered by an onWrite trigger on one of those documents. For illustration, let us say I have two documents A and B (in two separate collections). A first cloud function updates both documents A and B with a firestore WriteBatch (both documents are successfully updated); The write in document B triggers another cloud function (with an onWrite