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

2.14.11 • Public • Published

serverless fc starter

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

阿里云 FC

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

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

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

// for event
exports.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-fc-starter

Weekly Downloads

4

Version

2.14.11

License

MIT

Unpacked Size

14.8 kB

Total Files

6

Last publish

Collaborators

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