autoroute-express-promise
Advanced tools
Comparing version 0.2.1 to 0.2.2
{ | ||
"name": "autoroute-express-promise", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "autoroute for use with promises", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -81,5 +81,27 @@ # Auto-route Express Promise | ||
Example with two routes: | ||
Cleaner nested route syntax (version 0.2): | ||
```js | ||
var routes = { | ||
'/pets': { | ||
_methods: [ | ||
[ method.post, (req: Request) => getPet(req.body) ] ] | ||
':id': [ | ||
[ method.get, (req: Request) => getPet(req.params[ID]) ], | ||
[ method.delete, (req: Request) => petDied(req.params[ID]) ] ] | ||
}, | ||
'/cats': { | ||
':id': [ | ||
[ method.get, (req: Request) => getCat(req.params[ID]) ] ] | ||
'/hamsters': { // Overrides cats because of the forward slash at beginning | ||
'/fish': [ // Overrides hamsters (hamsters bite) | ||
[ method.get, (req: Request) => getFish(req.params[ID])] ] | ||
} | ||
} | ||
} | ||
``` | ||
Example with two routes (this is the old way, you can still do it this way.): | ||
```js | ||
import {method} from 'autoroute-express-promise' | ||
@@ -106,19 +128,2 @@ import {getPet, newPet, petDied} = require('../../pets') | ||
``` | ||
Cleaner nested route syntax (version 0.2+): | ||
```js | ||
var routes = { | ||
'/pets': { | ||
methods: [ | ||
[ method.post, (req: Request) => getPet(req.body) ] ] | ||
':id': { | ||
methods: [ | ||
[ method.get, (req: Request) => getPet(req.params[ID]) ], | ||
[ method.delete, (req: Request) => petDied(req.params[ID]) ] ] | ||
} | ||
} | ||
} | ||
``` | ||
## API | ||
@@ -125,0 +130,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
14030167
187