google-cloud-functions

Firebase deploy functions with Sharp library fails in Google Cloud Build

独自空忆成欢 提交于 2020-03-03 12:24:29
问题 After migrating to Google Cloud Build from Bitbucket Pipelines the Firebase deployment is failing. The setup was deploying successfully both on Bitbucket Pipelines and locally. No further explanation is given other than error below. I have comment parts of the code to to realize that "const sharp = require('sharp')" was one command that was making the build to fail. But there is no apparent reason why "firebase deploy" fails with "require('sharp')" and I have to way to tackle this. Firebase

Monitor Firebase Auth Object property changes?

青春壹個敷衍的年華 提交于 2020-03-01 10:11:41
问题 I've implemented by own email verification process using Firebase Auth and Firestore as I needed to use custom email templates. Client side, the UI is done with React. The process is as follows: 1) User registers and I call firebase.auth().createUserWithEmailAndPassword() 2) My Cloud Function listens for when a new user is created using functions.auth.user().onCreate() . It generates a record in Firestore using their UID as the doc ID, and sets a token and creation time. 3) The user clicks

Rate limiting for Google/Firebase cloud functions?

感情迁移 提交于 2020-02-27 08:27:20
问题 I am using Firebase to develop an app that uses Cloud Functions as a REST API internally. My question is, is there an easy way to implement per-IP/per-user rate-limiting similar to what slack uses, except on a per-IP and per-user basis, rather than per-app (since it's all one app). Optional support for small bursts is preferable as well. Example code (see the // TODO: comments): exports.myCoolFunction = functions.https.onRequest((req, res) => { // TODO: implement IP rate-limiting here

Use custom domain for firebase function http calls

蹲街弑〆低调 提交于 2020-02-26 12:51:31
问题 Is there a way to use a custom domain for firebase cloud functions http hooks. The default url for cloud functions looks something like this: https://us-central1-my-awesome-app.cloudfunctions.net/ios-oauth/ And I would like to make it look like this: https://myawesomeapp.com/ios-oauth/ I looked around if there was some other people looking for the same solution and sure enough I found this: https://stackoverflow.com/questions/43482224/firebase-cloud-functions-custom-domain 回答1: I have

Firebase hosting and cloud functions don't work with formidable: incomingForm is not a constructor

戏子无情 提交于 2020-02-26 03:41:05
问题 I use express to handle post requests and formidable to parse uploaded files: import * as admin from "firebase-admin"; import * as functions from "firebase-functions"; import * as formidable from "formidable"; import * as util from "util"; import * as express from "express"; admin.initializeApp(); const app = express(); app.post("/image", (req, res) => { const form = new formidable.incomingForm(); form.parse(req, async function(err, fields, files) { res.writeHead(200, { "content-type": "text

Firebase hosting and cloud functions don't work with formidable: incomingForm is not a constructor

拜拜、爱过 提交于 2020-02-26 03:41:04
问题 I use express to handle post requests and formidable to parse uploaded files: import * as admin from "firebase-admin"; import * as functions from "firebase-functions"; import * as formidable from "formidable"; import * as util from "util"; import * as express from "express"; admin.initializeApp(); const app = express(); app.post("/image", (req, res) => { const form = new formidable.incomingForm(); form.parse(req, async function(err, fields, files) { res.writeHead(200, { "content-type": "text

How to deploy multiple functions using gcloud command line?

最后都变了- 提交于 2020-02-25 06:57:25
问题 I want to deploy multiple cloud functions. Here is my index.js : const { batchMultipleMessage } = require('./gcf-1'); const { batchMultipleMessage2 } = require('./gcf-2'); module.exports = { batchMultipleMessage, batchMultipleMessage2 }; How can I use gcloud beta functions deploy xxx to deploy these two functions at one time. 回答1: Option 1: For now, I write a deploy.sh to deploy these two cloud functions at one time. TOPIC=batch-multiple-messages FUNCTION_NAME_1=batchMultipleMessage FUNCTION

Google Cloud Functions Python3: Wrapping HTTP trigger functions with endpoints

馋奶兔 提交于 2020-02-25 06:20:12
问题 I am exploring Google Cloud Functions in Python to write HTTP triggered functions. I have a main.py with all my triggered functions structured like in this post, but would like to be able to wrap in some endpoints. On nodejs, one could do so like in this post using Express , and on Python, very similarly using Flask . I have attempted to dabble by wrapping my Cloud Functions using Flask, but Google will bring me to Google's authentication page. My code as follows: from flask import Flask,

Google Cloud Functions Python3: Wrapping HTTP trigger functions with endpoints

半城伤御伤魂 提交于 2020-02-25 06:19:04
问题 I am exploring Google Cloud Functions in Python to write HTTP triggered functions. I have a main.py with all my triggered functions structured like in this post, but would like to be able to wrap in some endpoints. On nodejs, one could do so like in this post using Express , and on Python, very similarly using Flask . I have attempted to dabble by wrapping my Cloud Functions using Flask, but Google will bring me to Google's authentication page. My code as follows: from flask import Flask,

firebase import service throws error

二次信任 提交于 2020-02-24 05:10:06
问题 I'm using firebase functions and I want to initializeApp with service account key json into credential and I get the error Argument of type '{ "type": string; "project_id": string; "private_key_id": string; "private_key": string; "client_...' is not assignable to parameter of type 'string | ServiceAccount'. Type '{ "type": string; "project_id": string; "private_key_id": string; "private_key": string; "client_...' has no properties in common with type 'ServiceAccount'. my index.ts file import