Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Adding promise conversion proxy example
  • Loading branch information
darthtrevino committed Mar 18, 2015
1 parent aa1b9cd commit ffa7bd5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ jefferson(app, conf);
...
```

## Configuration
* 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 Conversion
```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);
}
}
}
}
```
## Installation

```bash
Expand Down

0 comments on commit ffa7bd5

Please sign in to comment.