gpt4 book ai didi

node.js - 是否可以使用 'firebase-admin' 包调用 firebase 函数?

转载 作者:行者123 更新时间:2023-12-05 01:32:59 25 4
gpt4 key购买 nike

我的 Node 应用程序具有基于服务帐户的访问权限,因此我使用了 firebase-admin。正如我之前看到的,firebase-admin 大部分都是重复的 firebase 包(身份验证部分、签名和其他一些部分除外),但现在我想调用函数,我找不到 firebase.apps[0].functions().httpsCallable('myFunction') 的任何等效项。我研究了 Typescript 类型,他们甚至没有提到函数。

admin.initializeApp({
credential: admin.credential.cert('./service-account-credentials.json'),
databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
});

const config = {
storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET,
};

const storageBucket = admin.storage().bucket(config.storageBucket);
const firestore = admin.firestore();



// const functions = admin.apps[0].functions(); // not possible
const functions = firebase.apps[0].functions(); // possible, but Firestore.apps not initialized

我有哪些选择?

最佳答案

Firebase 的 Node.js Admin SDK 中没有用于调用 Callable Cloud Functions 的 firebase-functions client

虽然这不是一个不合理的请求,所以我建议在 Github repo 上提交功能请求。 ,所以其他人也可以权衡。

与此同时,唯一的选择是实现 wire protocol for callable Cloud Functions你自己,可能基于他们的 implementation on the regular JavaScript SDK .

关于node.js - 是否可以使用 'firebase-admin' 包调用 firebase 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65060445/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com