Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Firebase函数索引.ts_Node.js_Typescript_Firebase_Import_Google Cloud Functions - Fatal编程技术网

Node.js Firebase函数索引.ts

Node.js Firebase函数索引.ts,node.js,typescript,firebase,import,google-cloud-functions,Node.js,Typescript,Firebase,Import,Google Cloud Functions,所以我使用firebase函数,作为我的API请求,一些函数做一些工作, 现在,我有1个'index.ts'文件,其中包含我的所有函数(14个函数),并带有以下签名: export const $function1 = functions.region(#region).runWith({ memory: '512MB' }).https.onRequest export const $function2 = functions.region(#region).https.onCall(asy

所以我使用firebase函数,作为我的API请求,一些函数做一些工作, 现在,我有1个'index.ts'文件,其中包含我的所有函数(14个函数),并带有以下签名:

export const $function1 = functions.region(#region).runWith({ memory: '512MB' }).https.onRequest

export const $function2 = functions.region(#region).https.onCall(async (data, context) => {
现在我的问题是如何组织这个“index.ts”

我的一些https请求验证令牌并检查有效的主体请求

组织此“index.ts”文件的最佳方式是什么

在每次不初始化AdminSDK的情况下,我是如何从该文件夹中的文件导出它的

我正在努力使这个文件夹尽可能地组织起来,因为在将来我需要添加越来越多的功能


谢谢你的帮助

这确实是个人的偏好,但通过Firebase文档组织函数的推荐方法是将所有函数写入它们自己的文件中,导出它们,然后在一个index.ts文件中初始化它们[1]。您还可以根据功能的用途(如身份验证或日志记录等)对其进行分组,然后将其导出到一个index.ts文件中。要了解更多信息,请查看我共享的文档,但正如我所说的,您可以用自己的方式组织它们


[1]

非常有帮助!我在搜索时没有找到此文档,非常感谢!