标签: google-cloud-functions

Firebase 的云函数:使用返回承诺的管理 sdk 更新/设置

在 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

0
推荐指数
1
解决办法
2012
查看次数

在 Cloud Functions 中使用 Selenium for Firebase

是否可以在 Cloud Functions for Firebase 中以某种方式运行 selenium?我找到了 AWS lambda 的解决方案,但找不到任何适合 Firebase 的解决方案。

firebase google-cloud-functions

0
推荐指数
1
解决办法
1273
查看次数

Firebase - 部署您的站点 - 删除云功能

如何在不删除云功能的情况下部署Firebase网站.

  1. 也许,在一个部署中包含站点和云功能?那是什么样的?
  2. 也许,在不删除云功能的情况下部署网站?我找不到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

firebase firebase-hosting google-cloud-functions

0
推荐指数
1
解决办法
115
查看次数

如何在新用户注册我们的应用程序时收到通知?

谁能告诉我,当新用户注册我的应用程序时,如何在我的应用程序上收到带有他们的邮件 ID 和名称的通知?

例如,我是一个用户将注册的应用程序的开发人员,我将为自己制作一个应用程序,以便在何时以及有多少用户注册我的生产应用程序时收到通知我使用 Firebase 进行身份验证,谁能给我一些关于这个的想法?

android firebase firebase-authentication google-cloud-functions firebase-cloud-messaging

0
推荐指数
1
解决办法
1547
查看次数

Cloud Functions for Firebase 是否遵守实时数据库规则?

我正在尝试使用特定节点的安全规则来保护我的实时数据库。

我了解 Firebase 规则在我使用我的设备写入/读取时适用。

如果写入/读取恰好来自 Cloud Functions,该怎么办?

如果我保护了(用户)节点,那么 Cloud Functions 是否知道(用户)是安全的?或者它无论如何都可以读写?

firebase firebase-security google-cloud-functions

0
推荐指数
1
解决办法
984
查看次数

admin.auth().currentUser; 在 Cloud Functions 中返回 undefined

我正在尝试创建一个函数,当设备在应用程序中注册时,会将这个设备 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

0
推荐指数
1
解决办法
2100
查看次数

Google Cloud Functions:Pub/Sub 与 Rest 触发

  1. Pub/Sub 在 Kubernetes Engine (GKE) api 服务器和 Cloud Function (GCF) 之间的通信方式是否明显更快?
  2. 是否可以使用 Pub/Sub 在来自一个 Google Cloud 项目的 GKE 和来自另一个 Google Cloud 项目的 GCF 之间进行此类通信?
  3. 以低延迟与来自另一个 Google Cloud 项目的 Cloud Functions 通信的方式是什么?

google-cloud-platform google-cloud-pubsub google-cloud-functions

0
推荐指数
1
解决办法
1395
查看次数

对Slack API使用Firebase onRequest()或Express app.use()

目标

使用@slack/interactive-messagefirebase-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

0
推荐指数
1
解决办法
352
查看次数

firecript函数在一个打字稿项目中部署错误,其中有几个通过git + https链接的打字稿依赖项

嗨,我有一个问题,当该项目包含另一个打字稿依赖时,通过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)

firebase typescript google-cloud-functions

0
推荐指数
1
解决办法
192
查看次数

除了Gogle Cloud Functions中的标准版本之外,是否可以使用其他Python实现?

我是Google Cloud Functions的新手。我想编写一个小型但执行密集的应用程序。我研究了文档,目前尚不清楚在部署到Google Cloud Functions时是否可以使用PyPy或CPython。

pypy cpython python-3.x google-cloud-platform google-cloud-functions

0
推荐指数
1
解决办法
60
查看次数