node.js - 将 ReasonML 函数部署到 Google Cloud Functions

标签 node.js google-cloud-functions reason bucklescript

我正在尝试编写一个部署过程,以获取 ReasonML .bs.js 输出并将其部署为 Google Cloud 函数。

这是 ReasonML 代码:

/*!
 * My first ReasonML Google cloud function.
 * Hadil G. Sabbagh
 */
open Express;

let helloworld2 = (req: Request.t) => (res: Response.t) => {
        Response.status(Response.StatusCode.Ok, res) |> 
Response.sendString("Hello world!");
};

我已经成功构建了一个 helloworld2.bs.js 文件。我一直在尝试使用 webpack 将所需的一切打包到一个 index.js 文件中,我可以将其作为 Google Cloud Function 运行,但我不知道如何公开我的函数名称以供 GCP 使用.

我正在使用 Node.js 8(测试版)。

最佳答案

感谢提供信息。我的代码依赖于 bs-express,它实际上是 ExpressJS 上的一个 ReasonML 层。这被埋在我的 node_modules 文件夹中,导致生成的 .bs.js 文件中的 require 语句失败。但是,我将依赖项复制到我的 src 目录并编辑了 helloworld2.bs.js 文件以指向它,它起作用了。

关于node.js - 将 ReasonML 函数部署到 Google Cloud Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52047175/

相关文章:

javascript - Firebase 未找到云功能?

node.js - 如何根据firestore文档的时间戳属性触发云函数

javascript - 如何在 ReasonML 中扩展 JS 类

javascript - 模块名称是绑定(bind)中使用的隐藏全局名称

node.js - 模式更改后如何从 mongo 中获取旧记录

javascript - Nodejs 请求 - 无法读取未定义的属性 'forEach'

node.js - 错误 : 'ngb-tab' is not a known element. Angular 11

node.js - 连接池和 lambda 终止

firebase - 我可以在自己的后端使用 Admin SDK 创建触发器吗?

ocaml - 未绑定(bind)记录字段 id 错误