在本地运行Firebase云端功能? [英] Run Firebase cloud functions locally?

查看:101
本文介绍了在本地运行Firebase云端功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中是否可以在本地运行Firebase云端功能?每次进行更改都需要花费很长时间才能部署到Firebase。



谢谢

更新(2017年9月):自版本3.11的Firebase工具/ CLI ,有一个云功能外壳,您可以使用它在本地测试您的功能,而无需部署它们。我推荐阅读博客文章使用云功能本地测试函数Shell 以及有关如何在本地运行函数的文档。



更新:自 firebase serve 时,它能够模拟HTTP功能。其他触发类型仍然不支持。



以前的回答



重新工作。与此同时,我会引用来自 firebase的Firebaser Doug -talk邮件列表


不幸的是,今天这个不存在。构建和测试云功能的本地环境是工程团队的首要任务。

同时,您可以抽象出函数的核心功能并调用它直接与节点命令行,传递它需要操作的所有必要的数据。例如,使用HTTPS函数,从请求对象中找出您需要的内容,将其输入到另一个函数,然后使用您创建的虚拟数据调用该函数。答复可以类似的方式处理。



Is it possible to run Firebase cloud functions locally during development? It takes a long time to deploy to firebase every time a change have been made.

Thanks

解决方案

firebaser here

Update (September 2017): since version 3.11 of the Firebase tools/CLI there is a Cloud Functions shell, which you can use to test your functions locally without deploying them. I recommend reading the blog post Testing Functions Locally with the Cloud Functions Shell and the documentation on how to Run Functions Locally.

Update: since version 3.8 of the Firebase tools/CLI, it has the ability to emulate HTTP functions when you run firebase serve. Other trigger types are still not supported though.

Previous answer

We're working on it. In the meantime, I'll quote fellow Firebaser Doug from the firebase-talk mailing list:

Unfortunately, this does not exist today. A local environment for building and testing Cloud Functions is a high priority for the engineering team.

In the meantime, you could abstract away the core functionality of your function and invoke it directly with the node command line, passing in all necessary data that it needs to operate. For example, with an HTTPS function, figure out what you need from the request object, make that the input to another function, then invoke that with dummy data that you create. The response could be handled similarly.

这篇关于在本地运行Firebase云端功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆