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

3.4.0 • Public • Published

Serverless SCF starter

本模块用于包裹无法定制运行时的 FaaS 平台,比如腾讯云 SCF。

腾讯云 SCF

import { asyncWrapper, start } from '@midwayjs/serverless-scf-starter';

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

// 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-scf-starter

Weekly Downloads

13

Version

3.4.0

License

MIT

Unpacked Size

11 kB

Total Files

7

Last publish

Collaborators

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