Skip to content

[Support] 怎么将 midwayjs 标准应用部署到 aws lambda? #3541

Answered by czy88840616
zuozuomuxi asked this question in Q&A
Discussion options

You must be logged in to vote

初始化完从 framework.getApplication() 拿到 app 就行。

// bootstrap.js
const { Bootstrap } = require('@midwayjs/bootstrap');
const { Framework } = require('@midwayjs/koa');
const serverlessExpress = require('@codegenie/serverless-express')

let serverlessExpressInstance;

async function setup (event, context) {

  // 初始化 miwday,拿到全局容器
  const container = await Bootstrap.run();
  // 拿到框架实例
  const framework = container.get(Framework);
  // 拿到 app
  const app = framework.getApplication();

  // 下面都是 serverlessExpress 文档上的异步获取用法
  serverlessExpressInstance = serverlessExpress({ app })
  return serverlessExpressInstance(event, context)
}

function handler (event, context) {
  if (serverlessExpressInstance)

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@czy88840616
Comment options

Answer selected by zuozuomuxi
@zuozuomuxi
Comment options

@czy88840616
Comment options

@zuozuomuxi
Comment options

@czy88840616
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
status: closed / duplicate This issue or pull request already closed or exists type: question / discussion This issue or pull request need be discussion
2 participants