JSPM

@midwayjs/serverless-fc-starter

3.4.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 93
  • Score
    100M100P100Q112454F
  • License MIT

Package Exports

  • @midwayjs/serverless-fc-starter
  • @midwayjs/serverless-fc-starter/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@midwayjs/serverless-fc-starter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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);
});