middleware-flow
Middleware control flow library
Installation
npm install middleware-flow
Examples
series(middlewares...)
var series = series;var app = ; app; // equivalent to app.use(mw1, mw2, mw3);
parallel(middlewares...)
var parallel = parallel;var app = ; // runs the middlewares in 'parallel'app; // if err, returns the first error that occurred
parallelWait(middlewares...)
var parallelWait = parallelWait;var app = ; // runs the middlewares in 'parallel' and waits for all of them before to return also in case of errapp; // if err, returns the first error that occurred
each
var each = each;var arr = 123;var app = ; // runs the middlewares in 'parallel'app; // if err, returns the first error that occurred
or(middlewares...)
var or = or;var app = ; // runs the middlewares in series, until one passes (no next(err));app; // if err, returns the first error that occurred
and(middlewares...)
Same as series.
if(value).then(middlewares...).else(middlewares...)
var if = if;var app = ; app;
syncIf(fn).then(middlewares...).else(middlewares...)
var syncIf = syncIf;var app = ; app; { return ;} { return val !== null && val !== undefined;}
asyncIf(fn).then(middlewares...).else(middlewares...)
var asyncIf = asyncIf;var or = or;var fs = ;var app = ; app; { fs;}
mwIf(middleware).then(middlewares..).else(middlewares..)
var mwIf = mwIf;var app = ; app; { if !requserisModerator ; else ; }
try(middlewares..).catch(middlewares..)
var flow = ;var app = ; app; { db;}
bg(middlewares...)
app; // runs the middlewares in series in the background