@midwayjs/serverless-aws-starter
TypeScript icon, indicating that this package has built-in type declarations

3.4.0 • Public • Published

serverless aws starter

this module is a light runtime starter for amazon lambda.

import { asyncWrapper, createRuntime } from '@midwayjs/serverless-aws-starter';

let runtime;
export.init = asyncWrapper(async () => {
  runtime = await createRuntime();
});

// for web request
export.handler = asyncWrapper(async (...args) => {
  return runtime.asyncEvent(async function(ctx) {
    return 'hello world';  // ctx.body = 'hello world';
  })(...args);
});

// for event
export.handler = asyncWrapper(async (...args) => {
  return runtime.asyncEvent(async function(ctx, event) {
    return {data: 1};
  })(...args);
});

Readme

Keywords

none

Package Sidebar

Install

npm i @midwayjs/serverless-aws-starter

Weekly Downloads

0

Version

3.4.0

License

MIT

Unpacked Size

15.7 kB

Total Files

11

Last publish

Collaborators

  • mariodu
  • czy88840616
  • legendecas
  • echosoar
  • lellansin
  • lxxyx
  • stone-jin