# faas-runtime

> - 支持koa（https://github.com/pillarjs/path-to-regexp） - 支持egg（https://eggjs.org/zh-cn/advanced/loader.html#%E6%89%A9%E5%B1%95-loader）

Latest version **1.2.0** (published 2019-11-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install faas-runtime
pnpm add faas-runtime
yarn add faas-runtime
bun add faas-runtime
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2019-11-07 |
| First published | 2019-06-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | langshu |

## Links

- npm: https://www.npmjs.com/package/faas-runtime
- Repository: https://github.com/ykfe/faas-runtime
- Homepage: https://github.com/ykfe/faas-runtime#readme
- Issues: https://github.com/ykfe/faas-runtime/issues
- npm.io page: https://npm.io/package/faas-runtime

## Dependencies (4)

- [koa](https://npm.io/package/koa.md) ^2.7.0
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.13.1
- [egg-core](https://npm.io/package/egg-core.md) ^4.17.2
- [koa-router](https://npm.io/package/koa-router.md) ^7.4.0

## Recent versions

- 1.2.0 (latest) — 2019-11-07
- 1.1.1 — 2019-11-07
- 1.1.2 — 2019-11-06
- 1.1.0 — 2019-09-16
- 1.0.2 — 2019-06-13
- 1.0.1 — 2019-06-04
- 1.0.0 — 2019-06-04

## README

# faas-runtime

- 支持koa（https://github.com/pillarjs/path-to-regexp）
- 支持egg（https://eggjs.org/zh-cn/advanced/loader.html#%E6%89%A9%E5%B1%95-loader）

## Install

```
$ npm i --save faas-runtime
```

## yml 文件规范

``` yml
functions:
  json: ## 方法名
    handler: api.json.handler ## 函数名
    events:
      - http:
          path: / ## 请求路径
          method: ## 支持的方法
            - GET
  user:
    handler: api.user.handler
    events:
      - http:
          path: /user/:id
          method:
            - GET
            - POST
```

## 如何使用

```js
const App = require('..')('egg', function (ctx, next) {
  ctx.rpc = function () {
    console.log('rpc')
  }
  console.log('before')
  return next().then(function () {
    console.log('next')
  })
})

const app = new App('./')

app.listen(3000, () => {
  console.log('server is listening on http://localhost:3000')
})

```

## Examples

测试用例

```js
$ cd example && node app.js
$ open http://localhost:3000/
$ open http://localhost:3000/user/1
```

---
_Source: https://npm.io/package/faas-runtime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
