You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

use-compose

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-compose

Compose use-* middlewares

0.4.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

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

Keywords

compose

FAQs

Package last updated on 01 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts