在 Cloud Functions for Firebase 中,例如:
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
.onWrite(event => {
//how to write data at another node and return promise?
return admin.database().ref(`/abc/1234`).update({a:1}); //is this the correct way?
})
Run Code Online (Sandbox Code Playgroud)
在https://firebase.google.com/docs/functions/get-started 中,它说
// You must return a Promise when performing asynchronous tasks inside a Functions such as
// writing to the Firebase Realtime Database.
// Setting an "uppercase" sibling in the Realtime Database returns a Promise.
Run Code Online (Sandbox Code Playgroud)
但在https://firebase.google.com/docs/database/admin/save-data 中,api 正在使用回调。我可以知道如何正确设置/更新 firebase 函数中的数据吗?该代码将起作用,但我不确定我是否正确执行或者它是否是推荐的方式。谢谢。
javascript firebase firebase-realtime-database google-cloud-functions
是否可以在 Cloud Functions for Firebase 中以某种方式运行 selenium?我找到了 AWS lambda 的解决方案,但找不到任何适合 Firebase 的解决方案。
如何在不删除云功能的情况下部署Firebase网站.
firebase deploy --only site或类似的我有一个使用云功能的Firebase项目.代码位于两个文件夹中:
-site-code
-cloud_function-code
Run Code Online (Sandbox Code Playgroud)
当我想部署项目时,我使用firebase CLI工具,分两步:
步骤1
从-site-code我跑:
firebase deploy
Run Code Online (Sandbox Code Playgroud)
第2步
然后从cloud_functions-code我运行:
firebase deploy --only functions
Run Code Online (Sandbox Code Playgroud)
当我运行firebase deploy 从 -site-code我的火力地堡云功能都被删除了,所以我必须跟进firebase deploy --only functions 的 -cloud_functions-code.
我没有找到--only仅部署站点代码的指令-site-code
谁能告诉我,当新用户注册我的应用程序时,如何在我的应用程序上收到带有他们的邮件 ID 和名称的通知?
例如,我是一个用户将注册的应用程序的开发人员,我将为自己制作一个应用程序,以便在何时以及有多少用户注册我的生产应用程序时收到通知我使用 Firebase 进行身份验证,谁能给我一些关于这个的想法?
android firebase firebase-authentication google-cloud-functions firebase-cloud-messaging
我正在尝试使用特定节点的安全规则来保护我的实时数据库。
我了解 Firebase 规则在我使用我的设备写入/读取时适用。
如果写入/读取恰好来自 Cloud Functions,该怎么办?
如果我保护了(用户)节点,那么 Cloud Functions 是否知道(用户)是安全的?或者它无论如何都可以读写?
我正在尝试创建一个函数,当设备在应用程序中注册时,会将这个设备 uid 附加到注册该设备的登录用户的 uid(这是在另一个 firestore 集合中,当用户寄存器)。
这是我的代码:
exports.addDeviceToUser = functions.firestore.document('device-names/{device}').onUpdate((change, context) => {
const currentUser = admin.auth().currentUser;
const deviceName = context.params.device;
var usersRef = db.collection('users');
var queryRef = usersRef.where('uid', '==', currentUser.uid);
if (authVar.exists) {
return queryRef.update({sensors: deviceName}).then((writeResult => {
return console.log('Device attached');
}));
} else {return console.log('Device attachment failed, user not signed in');}
});Run Code Online (Sandbox Code Playgroud)
我一直收到此错误:“类型错误:无法读取未定义的属性 'uid'。” 显然我无法访问当前用户的身份验证信息。为什么?
javascript firebase firebase-authentication google-cloud-functions google-cloud-firestore
google-cloud-platform google-cloud-pubsub google-cloud-functions
使用@slack/interactive-message包firebase-functions来监听和响应Slack消息和对话框.
我不确定如何使用@slack/interactive-messagefirebase 的监听器.
1)我是否使用Firebase functions.https.onRequest(),并以某种方式req从Slack 传递到 slackInteractions.action()?
要么
2)我使用的app.use("/app", slackInteractions.expressMiddleware());如果是这样,你在哪里slackInteractions.action()小号去?
要么
3)还有别的吗?
// Express
import express = require("express");
const app = express();
const cors = require("cors")({
origin: "*"
});
app.use("*", cors);
// Firebase Functions SDK
import functions = require("firebase-functions");
const slackbotConfig = functions.config().slackbot;
const { createMessageAdapter } = require("@slack/interactive-messages");
const slackInteractions = createMessageAdapter(slackbotConfig.signing_secret);
app.use("/app", slackInteractions.expressMiddleware());
// Express route
app.post("/go", (req, …Run Code Online (Sandbox Code Playgroud) middleware express firebase slack-api google-cloud-functions
嗨,我有一个问题,当该项目包含另一个打字稿依赖时,通过firebase-tools将我的typescript express应用程序部署到firebase.在谷歌功能中运行时,构建过程可能出现问题.请注意,程序在本地按预期工作,这只是部署的问题.
这是MVE的回购:
https://github.com/jk89/baseRepo
这加载了两个依赖:
https://github.com/jk89/depRepo1
https://github.com/jk89/depRepo2
我从firebase-tools'firebase deploy'得到以下错误:
jty@carrot:~/April2018/typescript-min-ver/baseRepo$ firebase deploy
=== Deploying to 'pricecalculator-e88d6'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run build
> base-repo@0.1.0 build /home/jty/April2018/typescript-min-ver/baseRepo
> npm run tslint && tsc --declaration
> base-repo@0.1.0 tslint /home/jty/April2018/typescript-min-ver/baseRepo
> tslint -c tslint.json -p tsconfig.json
? functions: Finished running predeploy script.
i functions: ensuring necessary APIs are enabled...
? functions: all necessary APIs are enabled
i functions: preparing . directory for uploading...
i functions: packaged . (12.76 KB) …Run Code Online (Sandbox Code Playgroud) 我是Google Cloud Functions的新手。我想编写一个小型但执行密集的应用程序。我研究了文档,目前尚不清楚在部署到Google Cloud Functions时是否可以使用PyPy或CPython。
pypy cpython python-3.x google-cloud-platform google-cloud-functions
firebase ×8
javascript ×2
android ×1
cpython ×1
express ×1
middleware ×1
pypy ×1
python-3.x ×1
slack-api ×1
typescript ×1