0.4.0 • Published 7 years ago

use-compose v0.4.0

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

Compose use-* middlewares

Compose middlewares like fn(req, resp, next) into one.
Support async middleware which return promise.

Examples

const compose = require('use-compose');
const theone = compose([
  async (req, resp, next)=>{
    await sleep(1);
    const result = await next()
    await sleep(1);
    return result;
  },
  (req, resp, next)=>{
    return new Promise((resolve, reject)=>{
      resolve(1)
    })
  }
])

//call the composed one
theone(req, resp).then(result=>assert.equal(result, 1));

API

compose(middlewares, options). options have:

  • inheritProperties: the properties that will be passed to middlewares from the result composed function
  • canRunMiddleware: before invoking the specified middleware, check whether it can be run

License

Licensed under MIT

Copyright (c) 2016 kiliwalk

0.4.0

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago