如何在云函数中使用快速替代的Koa库?
我知道KOA使用所有优秀的ES2017,并更多地使用JavaScript的异步使用。
或者它可能根本不需要使用云函数,因为Firebase系统在结束前一个调用之前不会向同一个云函数发送多个调用?
我不清楚。
它知道需要Node 8.x,我知道NodeJs 8.9.x,现在有LTS。
发布于 2018-05-31 06:43:35
从云函数doc中读取:
基础镜像云函数使用基于Debian的执行环境,包括gcr.io/google-appengine/nodejs Docker镜像的内容,Node.js运行时安装在上面指定的版本中:
FROM gcr.io/google-appengine/nodejs
RUN install_node v6.14.0要查看映像中包含的内容,您可以检查其GitHub project,或者拉取并检查映像本身。对语言运行时(Node.js)的更新通常是自动完成的(除非另行通知),并包括基础映像定义中的任何更改。
我在2017年11月看到了一个添加了Nodejs v8的pull request。希望它能最终登陆Google Cloud Functions
更新:谷歌云函数现在支持Node.js 8 and even Python!
发布于 2018-01-17 03:32:47
参考Google的发行说明...Cloud Functions Release Notes
支持的节点版本仍然是v6,对于firebase也是如此。在他们在v8中发布它之前,你需要等待一段时间。我非常确定当v6不再支持时,他们会转移到v8,但希望更早……
发布于 2018-07-18 04:01:37
Use babel:
index.js:
----------=
'use strict';
require('@babel/register')
require('babel-polyfill')
const http = require('http')
const createApp = require('./app/app.js')
const handle = createApp().callback()
if (process.env.IS_LOCAL_DEPLOYMENT) {
// to use same code in local server
http.createServer(handle).listen(3000)
} else {
module.exports.http = (request, response) => {
handle(request, response)
};
}
app.js:
--------
'use strict';
const Koa = require('koa')
module.exports = () => {
const app = new Koa()
app.use(......)
return app
}
package.json
------------
"scripts": {
.
.
"start": "export IS_LOCAL_DEPLOYMENT=true && node index"
.
.
}https://stackoverflow.com/questions/47712018
复制相似问题