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

3.13.1 • Public • Published

serverless worker starter

本模块用于包裹无法定制运行时的 FaaS 平台,比如阿里云 FC。

Serverless Worker

import { eventWaitUntil, eventRespondWith, start } from '@midwayjs/serverless-worker-starter';

let runtime;
addEventListener('install', eventWaitUntil(async event => {
  runtime = await start();
}));

addEventListener('fetch', eventRespondWith(async event => {
  return runtime.asyncEvent(async function(ctx) {
    return 'hello world';  // ctx.body = 'hello world';
  })(event);
}));

Readme

Keywords

none

Package Sidebar

Install

npm i @midwayjs/serverless-worker-starter

Weekly Downloads

1

Version

3.13.1

License

MIT

Unpacked Size

21.6 kB

Total Files

12

Last publish

Collaborators

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