google-cloud-functions

Generating Swagger Docs in Firebase Cloud Functions project

点点圈 提交于 2020-05-25 11:26:41
问题 Is it possible to generate Swagger Spec file from function comments in firebase cloud functions? If so, how can we do it? I see the cloud functions code to be more like serverless, so wondering if this is possible. 回答1: I haven't found an automatic way, but there are plenty of libraries to choose from. I'm using express and nodejs in my Firebase Function implementations, and for me, Swagger doc generation can be implemented via the following libraries: https://github.com/scottie1984/swagger

unable to split Firebase functions in multiple files

无人久伴 提交于 2020-05-24 21:33:25
问题 I'm working with firebase functions and arrived to hundreds of functions, and now it is very hard to manage it in single index.js file as shown in their lots of examples I tried to split that functions in multiple files like: --firebase.json --functions --node_modules --index.js --package.json --app --groupFunctions.js --authFunctions.js --storageFunctions.js In this structure i divide my functions in three categories and put in that three files groupFunctions.js , authFunctions.js , and

unable to split Firebase functions in multiple files

末鹿安然 提交于 2020-05-24 21:32:06
问题 I'm working with firebase functions and arrived to hundreds of functions, and now it is very hard to manage it in single index.js file as shown in their lots of examples I tried to split that functions in multiple files like: --firebase.json --functions --node_modules --index.js --package.json --app --groupFunctions.js --authFunctions.js --storageFunctions.js In this structure i divide my functions in three categories and put in that three files groupFunctions.js , authFunctions.js , and

How to fix Typescript error “Object is possibly 'undefined'”

守給你的承諾、 提交于 2020-05-24 04:15:31
问题 I'm building a cloud function that will use the Stripe API to process payments. This is within a firebase project. When I run firebase deploy I get the error "Object is possible 'undefined'" const existingSource = customer.sources.data.filter( (s) => s.id === source).pop(); I'm not sure how to resolve this. Here is my index.ts import * as functions from 'firebase-functions'; export { stripeAttachSource } from './sources'; export { stripeCreateCharge, stripeGetCharges } from './charges';

Cannot find module 'serviceAccountKey.json'

可紊 提交于 2020-05-24 03:30:31
问题 I'm trying to implement Firebase Functions and I'm stuck at importing my service account key from my project. This is my code. import * as admin from 'firebase-admin'; var serviceAccount = require('./' + functions.config().environment.name + '/serviceAccountKey.json'); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "<MYDATABASEURL>.firebaseio.com" }); When I run firebase serve this is the output Cannot find module './development/serviceAccountKey.json'

Cannot find module 'serviceAccountKey.json'

本小妞迷上赌 提交于 2020-05-24 03:30:28
问题 I'm trying to implement Firebase Functions and I'm stuck at importing my service account key from my project. This is my code. import * as admin from 'firebase-admin'; var serviceAccount = require('./' + functions.config().environment.name + '/serviceAccountKey.json'); admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: "<MYDATABASEURL>.firebaseio.com" }); When I run firebase serve this is the output Cannot find module './development/serviceAccountKey.json'

ReactorNotRestartable with scrapy when using Google Cloud Functions

不问归期 提交于 2020-05-23 11:14:51
问题 I am trying to send multiple crawl requests with Google Cloud Functions. However, I seem to be getting the ReactorNotRestartable error. From other posts on StackOverflow, such as this one, I understand that this comes because it is not possible to restart the reactor, in particular when doing a loop. The way to solve this is by putting the start() outside the for loop. However, with Cloud Functions this is not possible as each request should be technically independent. Is the CrawlerProcess

Firebase function (written in NodeJS) to delete file from Cloud Storage when an object is removed from Realtime Database

℡╲_俬逩灬. 提交于 2020-05-23 04:34:04
问题 I am new to NodeJS and I am trying to write the next method for Cloud Functions for Firebase. What I am trying to achieve: The function should be triggered when the user removes a Photo object from Firebase DB; The code should remove the file object from Storage corresponding to the Photo obj. These is my Firebase DB structure: photos/{userUID}/{photoUID} { "dateCreated": "2017-07-27T16:40:31.000000Z", "isProfilePhoto": true, "isSafe": true, "uid": "{photoUID}", "userUID": "{userUID}" } And

Close redis connection on google cloud function end

大城市里の小女人 提交于 2020-05-18 01:54:07
问题 How do you close the connection to a redis memory store from a cloud function when the cloud function instance terminates? (I believe to close I need to call redis.quit(), but I just don't know when, and I cannot close them immediately after a function returns because the function instance can be reused) Because I'm just leaving the connections open, right now I am getting "ECONNRESET" errors. Alternatively if something like this is not possible: process.on("exit", function(){//also process

Close redis connection on google cloud function end

不羁岁月 提交于 2020-05-18 01:53:08
问题 How do you close the connection to a redis memory store from a cloud function when the cloud function instance terminates? (I believe to close I need to call redis.quit(), but I just don't know when, and I cannot close them immediately after a function returns because the function instance can be reused) Because I'm just leaving the connections open, right now I am getting "ECONNRESET" errors. Alternatively if something like this is not possible: process.on("exit", function(){//also process