otware

0.1.1 • Public • Published

ot-ware

one at time middle(ware) layer.

why?

in one of my projects i needed to have a middleware whose run functions block were executable one at time.

installation

$ npm install otware

usage

var otware = require('otware');
var middleware = otware()
  .use(function (req, res, next) {
    res.x = 'hello';
    next();
  })
  .use(function (req, res, next) {
    res.y = 'world';
    //wait 3 seconds before call the next function
    setTimeout(function(){
        next();
    },3000);
  });
 
//first run
middleware.run({}, {}, function (err, req, res) {
  res.x; // "hello"
  res.y; // "world"
});
 
//this run will be executed after the first run(about 3 seconds after)
middleware.run({}, {}, function (err, req, res) {
  res.x; // "hello"
  res.y; // "world"
});

Readme

Keywords

Package Sidebar

Install

npm i otware

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • zetae