Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Update osprey-router with uri param re-use
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Feb 11, 2016
1 parent 85b321f commit ae2f940
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,25 @@ app.post('/users/{userId}', function (req, res, next) {

All parameters are automatically validated and parsed to the correct types according to the RAML document using [raml-validate](https://github.com/mulesoft/node-raml-validate) and [raml-sanitize](https://github.com/mulesoft/node-raml-sanitize). URL parameter validation comes with [Osprey Router](https://github.com/mulesoft-labs/osprey-router), available using `osprey.Router`.

```js
// Similar to `express.Router`, but uses RAML paths.
var Router = require('osprey').Router

var app = new Router()

app.use(...)

app.get('/{slug}', {
slug: {
type: 'string'
}
}, function (req, res) {
res.send('success')
})

module.exports = app
```

#### Handling Errors

Osprey returns a [middleware router instance](https://github.com/pillarjs/router), so you can mount this within any compatible application and handle errors with the framework. For example, using HTTP with [finalhandler](https://github.com/pillarjs/finalhandler) (the same module Express uses):
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
"invariant": "^2.1.0",
"oauth2orize": "^1.0.1",
"osprey-method-handler": "^0.10.0",
"osprey-resources": "^0.4.0",
"osprey-router": "^0.1.1",
"osprey-resources": "^0.5.0",
"osprey-router": "^0.2.0",
"parseurl": "^1.3.0",
"passport": "^0.3.0",
"passport-http": "^0.3.0",
Expand All @@ -81,6 +81,6 @@
"popsicle-server": "^1.0.0",
"pre-commit": "^1.0.5",
"server-address": "^1.0.1",
"standard": "^5.0.0"
"standard": "^6.0.4"
}
}

0 comments on commit ae2f940

Please sign in to comment.