express-errors-handler
Some middleware for Express and Node that sets up Raven (or not as appropriate) depending on sensible environment variables.
Installation
npm install --save express-errors-handler
Usage
var express = require('express');
var app = express();
var eeh = require('express-errors-handler')
var errorMiddleware = eeh.middleware;
var promiseEnabledApi = require('./my-promise-enabled-api');
app.get('/a-typical-route', function(req, res, next) {
promiseEnabledApi.getSomeThings()
.then(function(someThings) {
res.render(someThings);
})
.catch(next);
});
app.get('/a-typical-route', function(req, res, next) {
fetch('http://a.url.i-like')
.then(function(someThings) {
res.render(someThings);
})
.catch(eeh.upstreamErrorHandler(404))
.catch(next);
});
app.use(errorMiddleware);
Supported environment variables
NODE_ENV
- mode to operate in, can be either PRODUCTION
(sends bugs to aggregator) or any another value (shows bugs to user)RAVEN_URL
- URL to report bugs captured in productionSPLUNK_URL
- URL to send non critical or upstream bugs too
License
This software is published by the Financial Times under the MIT license.