google-cloud-functions

Create PDF in Firebase Cloud Functions

半城伤御伤魂 提交于 2020-01-12 03:36:29
问题 I am new to javascript and I'm trying to make a PDF file from a firebase function using pdfkit. Below is my function code. const pdfkit = require('pdfkit'); const fs = require('fs'); exports.PDFTest = functions.https.onRequest((req, res) => { var doc = new pdfkit(); var loremIpsum = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in...'; doc.y = 320; doc.fillColor('black') doc.text(loremIpsum, { paragraphGap: 10, indent: 20, align: 'justify', columns: 2 }); doc.pipe( res

Firebase functions how to send a notification in Android

China☆狼群 提交于 2020-01-11 13:40:06
问题 I want that every time that chat is modified from the firebase database this function is activated "sendNotification" but this error appears: sendNotification ReferenceError: receiverId is not defined at exports.sendNotification.functions.database.ref.onWrite.event (/user_code/index.js:11:29) at cloudFunctionNewSignature (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:105:23) at cloudFunction (/user_code/node_modules/firebase-functions/lib/cloud-functions.js:135:20) at /var

Firebase Storage & Cloud Functions - ECONNRESET

我是研究僧i 提交于 2020-01-10 02:10:13
问题 I developed a Firebase Cloud function that processes several manipulations on uploaded images. My code is based on this documentation article and this Cloud Function example. Hence, it is using Google Cloud Storage package. It is working fine almost all the time, but sometimes I am getting this error when uploading to or deleting from Storage : Error: read ECONNRESET at exports._errnoException (util.js:1026:11) at TLSWrap.onread (net.js:569:26) I am using the default bucket of my application,

How can I keep Google Cloud Functions warm?

隐身守侯 提交于 2020-01-09 10:06:35
问题 I know this misses the point of using Cloud Functions in the first place, but in my specific case, I'm using Cloud Functions because it's the only way I can bridge Next.js with Firebase Hosting. I don't need to make it cost-efficient, etc. With that said, the cold boot times for Cloud Functions are simply unbearable and not production-ready, averaging around 10 to 15 SECONDS for my boilerplate. I've certainly watched this video by Google (https://www.youtube.com/watch?v=IOXrwFqR6kY) that

Cloud Functions for Firebase: Increment Counter

≯℡__Kan透↙ 提交于 2020-01-09 08:54:47
问题 Is it acceptable to increment a counter with a realtime database trigger using transaction? exports.incPostCount = functions.database.ref('/threadsMeta/{threadId}/posts') .onWrite(event => { admin.database().ref('/analytics/postCount') .transaction(count => { if (count === null) { return count = 1 } else { return count + 1 } }) }); 回答1: Definitely! In fact, that's exactly how it's done in this code sample, although with a few small differences: exports.countlikechange = functions.database.ref

Creating a Data Pipeline to BigQuery Using Cloud Functions and Cloud Scheduler

夙愿已清 提交于 2020-01-07 08:07:39
问题 I am trying to build a Data Pipeline that will download the data from this website and push it to a BigQuery Table. def OH_Data_Pipeline(trigger='Yes'): if trigger=='Yes': import pandas as pd import pandas_gbq import datetime schema=[{'name': 'SOS_VOTERID', 'type': 'STRING'},{'name': 'COUNTY_NUMBER', 'type': 'STRING'}, {'name': 'COUNTY_ID', 'type': 'INT64'}, {'name': 'LAST_NAME', 'type': 'STRING'}, {'name': 'FIRST_NAME', 'type': 'STRING'}, {'name': 'MIDDLE_NAME', 'type': 'STRING'}, {'name':

How to update multiple children under child node using a transaction?

*爱你&永不变心* 提交于 2020-01-06 08:44:48
问题 Here's my data structure, how it is organized (firebase database): -database -productsList -item1: 0 -item2: 0 -item3: 0 -item4: 0 -orders -order1: -... -order2: -... -... I'm building a shopping app that has a list of products. Customers can choose what they want to buy and make an order. When they do the product's quantities would increase based on what they've chosen. Say a customer chose to buy 2 units of item2 e 5 units of item4, when one sends a request it will write at a different

How to update multiple children under child node using a transaction?

别来无恙 提交于 2020-01-06 08:44:07
问题 Here's my data structure, how it is organized (firebase database): -database -productsList -item1: 0 -item2: 0 -item3: 0 -item4: 0 -orders -order1: -... -order2: -... -... I'm building a shopping app that has a list of products. Customers can choose what they want to buy and make an order. When they do the product's quantities would increase based on what they've chosen. Say a customer chose to buy 2 units of item2 e 5 units of item4, when one sends a request it will write at a different

Cloud Function deletes node instantly instead of after two hours based off timestamp (delete-old-child-nodes not working)

梦想的初衷 提交于 2020-01-06 08:36:15
问题 I am trying to implement the "delete-old-child-nodes" Cloud Functions example (https://github.com/firebase/functions-samples/tree/master/delete-old-child-nodes). When the directory is written to, it should delete all nodes that are 2+ hours old. However, it just deletes all nodes no matter what. I found this StackOverflow post that describes the same issue. However, I believe the cause is different. The user was storing his timestamp in seconds, while the cutoff was in milliseconds. In my

Firebase Functions - admin.messaging().sendToTopic executes but never makes it to the `then` block

送分小仙女□ 提交于 2020-01-06 08:16:56
问题 For some reason the then block of an admin function doesn't seem to be executing - I don't see any of the console.log messages in the firebase console : Here is all of my firebase functions code: // The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers. const functions = require('firebase-functions'); const firebaseHelper = require('firebase-functions-helper'); const serviceAccount = require('./serviceAccountKey.json'); var toPlainObject = require('lodash