Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floatdrop/wrap-middleware
Wraps middleware
https://github.com/floatdrop/wrap-middleware
Last synced: about 1 month ago
JSON representation
Wraps middleware
- Host: GitHub
- URL: https://github.com/floatdrop/wrap-middleware
- Owner: floatdrop
- License: mit
- Created: 2015-04-14T13:14:34.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-14T16:03:36.000Z (almost 10 years ago)
- Last Synced: 2024-10-28T00:04:54.027Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 141 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# wrap-middleware [![Build Status](https://travis-ci.org/floatdrop/wrap-middleware.svg?branch=master)](https://travis-ci.org/floatdrop/wrap-middleware)
Wraps middleware and provide way to attach code before and after it.
## Install
```
$ npm install --save wrap-middleware
```## Usage
```js
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](http://github.yandex-team.ru/floatdrop)