Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psirenny/derby-error
Add standard error routes to a Derby JS app.
https://github.com/psirenny/derby-error
Last synced: 24 days ago
JSON representation
Add standard error routes to a Derby JS app.
- Host: GitHub
- URL: https://github.com/psirenny/derby-error
- Owner: psirenny
- License: mit
- Created: 2014-01-27T17:06:38.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-24T15:56:28.000Z (almost 10 years ago)
- Last Synced: 2024-10-30T16:44:29.009Z (about 1 month ago)
- Language: JavaScript
- Size: 199 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-derby - derby-error - Add standard error routes to a Derby JS app (Information)
README
Derby Error
===========[Derby JS](http://derbyjs.com) middleware that adds default error handling redirects.
For example:
http://site.com/unknown/path => http://site.com/error/404
Why should I use this?
----------------------It allows your client app to handle errors the same way you'd handle normal page requests.
Simply add a route for **/error/:code**.
Now there's no need to create a static app to handle errors.
Of course, you can still do that if you'd like.Installation
------------$ npm install derby-error --save
In your server file:
var error = require('derby-error');
expressApp
// ...
// ...
// place after all other middleware
.use(error());Usage
-----Create an error handling route:
// assumes you have views such as: 404.html, 500.html, etc.
app.get('/error/:code', function (page, model, params) {
page.render(params.code);
});