app-builder

Promise based composable functions for middleware

MIT 27 个版本
安装
npm install app-builder
yarn add app-builder
pnpm add app-builder
bun add app-builder
README

app-builder

Actions Status

Create composable promise based middleware pipelines, using the "onion" middleware model.

Install:

npm install app-builder

Example

import { compose } from 'app-builder'

const app = compose([
  async function (ctx, next) {
    ctx.value += 1
    await next()
    ctx.value += 4
  },
  async function (ctx, next) {
    ctx.value += 2
    await next()
    ctx.value += 3
  }
]);

const context = { value: '' }
app(context).then(() => console.log(context.value)) // --> '1234'

All composed functions are also valid middleware functions.

const superApp = compose(
  async function (ctx, next) {
    ctx.value += 'first'
    await next()
    ctx.value += 'last'
  },
  app
)
版本列表
7.0.4 2021-06-27
7.0.3 2021-06-27
7.0.2 2021-06-06
7.0.1 2021-06-06
7.0.0 2021-04-10
6.2.2 2020-04-23
6.2.1 2020-03-15
6.2.0 2020-01-20
6.1.0 2020-01-11
6.0.0 2019-10-11
5.2.0 2018-01-13
5.1.2 2018-01-12
5.1.1 2017-11-27
5.1.0 2017-03-15
5.0.7 2016-08-29
5.0.6 2016-07-10
5.0.5 2016-07-06
5.0.4 2016-07-05
5.0.3 2016-07-05
5.0.1 2016-01-12
5.0.0 2015-11-15
4.1.2 2015-10-23
4.1.1 2015-10-08
4.1.0 2015-10-04
4.0.0 2015-10-04
3.0.1 2015-07-25
3.0.0 2015-07-24