Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
darthtrevino committed Mar 18, 2015
1 parent f73dcfa commit 657c903
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,11 @@ jefferson(app, conf);
* routes: (optional) - An map of routes by name. Each object in the map describes an endpoint to be wired. These endpoints must contain an HTTP method, a path, and an array of middleware functions.
* proxies: (optional) - An array of proxy objects invoked around all middleware functions in order. Each proxy object should have an init() function that accepts a delegate middleware function and returns a new middleware function.

## Examples
* Promise-Based Middleware Proxy
```js
{
name: 'Promise Conversion',
init: (delegate) => {
return (req, res, next) => {
if (delegate.length === 2) {
Promise.resolve(true)
.then(() => delegate(req, res))
.then(() => next())
.catch(next);
} else {
return delegate(req, res, next);
}
}
}
}
```
## Boilerplate Proxies
### Promise-Based Middleware Proxy
`require('express-jefferson/proxies/promise-handler')`

This proxy accepts promise-based middleware (middleware that accepts two arguments) and wraps them in a promise chain before invoking next().
## Installation

```bash
Expand Down

0 comments on commit 657c903

Please sign in to comment.