我们如何使用函数框架一次运行所有的谷歌云函数

问题描述 投票:0回答:1

是否可以同时运行我们的所有功能,而无需编写自定义脚本或将我们的功能包装在 Express 应用程序中。

我期待这样的事情:

npx @google-cloud/functions-framework myfolder

但是文档中没有提及任何内容。 我们有很多功能,因此必须编写我们不会使用的自定义脚本,我们将坚持使用 firebase 模拟器

google-cloud-platform google-cloud-functions functions-framework
1个回答
0
投票

正如 guillaume blaquiere 在评论中所说,目前还不可能,[github][1] 上也提出了一个请求,@dupski 分享了一个解决方法

为此找到了一个简单的解决方法 - 只需定义一个“索引”函数,然后调用其他函数进行本地开发,例如:

  switch (req.path) {
    case '/oauth2_init':
      return oauth2_init(req, res)
    case '/oauth2_callback':
      return oauth2_callback(req, res)
    case '/my_func':
      return my_func(req, res)
    default:
      res.send('function not defined')
  }
}```

and have that as the target when running the function framework locally, i.e.:

```npx @google-cloud/functions-framework --target=index```

If the workaround in the github does not answer, you may try adding your concern over there 
 further progress can be tracked there.
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.