【问题标题】:AWS Serverless Express in local environment本地环境中的 AWS Serverless Express
【发布时间】:2018-11-13 20:16:20
【问题描述】:

我想在本地环境中使用AWS Serverless Express,以便轻松使用 Lambda 函数。

npm run local 不会启动 Web 服务器,而是使用 api-gateway-event.json 文件执行一次 Lambda 函数。

有没有人知道一些允许使用执行 Lambda 函数的 Web 服务器进行本地开发的工具? 这样做有什么最佳做法吗?

【问题讨论】:

    标签: amazon-web-services serverless aws-serverless


    【解决方案1】:

    查看 AWS Serverless Express 项目 herebasic-starter 示例中的 app.local.js 脚本。

    app.local.js

    这是应用文件的本地版本,其中包含:

    const app = require('./app')
    const port = 3000
    
    app.listen(port)
    console.log(`listening on http://localhost:${port}`)
    

    本地命令

    然后您使用以下命令运行本地实例:

    node app.local.js

    部署

    有关在本地使用 AWS 服务及其部署过程的更多信息,本文也可能有所帮助:Deploy a REST API using Serverless, Express and Node.js

    【讨论】:

      猜你喜欢
      • 2020-03-27
      • 2021-08-08
      • 1970-01-01
      • 2018-06-14
      • 2020-09-22
      • 2020-04-29
      • 2019-12-02
      • 2020-09-14
      • 2020-06-29
      相关资源
      最近更新 更多