fcapi

1.2.2 • Public • Published

Fcapi

云函数http触发器实现api接口

安装

npm i fcapi

使用

  • 只接受POST方法,其他类型的请求将被拒绝并返回500错误
  • 不解析URL参数
  • 请求体只接受JSON格式的数据,并且需要设置Content-Type
  • 返回的函数是底部函数,可以和其他中间件配合使用,如:mongoing
  • 逻辑内部可直接抛出错误,错误将作为结果返回
const fcapi = require('fcapi')
 
exports.handler = fcapi(async (event, context) => {
    switch(event.type){
        case 'one':
            return await one(event)
        case 'another':
            return await two(event)
        default:
            throw 'Unknown type'
    }
})

/fcapi/

    Package Sidebar

    Install

    npm i fcapi

    Weekly Downloads

    3

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    2.12 kB

    Total Files

    3

    Last publish

    Collaborators

    • orzv