wrap-middleware

My good module

Usage no npm install needed!

<script type="module">
  import wrapMiddleware from 'https://cdn.skypack.dev/wrap-middleware';
</script>

README

wrap-middleware Build Status

Wraps middleware and provide way to attach code before and after it.

Install

$ npm install --save wrap-middleware

Usage

var wrapMiddleware = require('wrap-middleware');
var myMw = function (req, res, next) { next(); };

wrapMiddleware(myMw)
    .before(function (req, res, next) {
        // Called before
    })
    .after(function (req, res, next) {
        // Called after
    });
//=> wrapped middleware

API

wrapMiddleware(middleware)

middleware

Required
Type: Function

Middleware, that should be wrapped.

.before(cb)

Attaches cb, that will be called before wrapped middleware.

.after(cb)

Attaches cb, that will be called after wrapped middleware.

License

MIT © Vsevolod Strukchinsky