{ "html": "
Raven is distributed via npm
:
$ npm install raven --save\n
var app = require('express')();\nvar Raven = require('raven');\n\n// Must configure Raven before doing anything else with it\nRaven.config('__DSN__').install();\n\n// The request handler must be the first middleware on the app\napp.use(Raven.requestHandler());\n\napp.get('/', function mainHandler(req, res) {\n throw new Error('Broke!');\n});\n\n// The error handler must be before any other error middleware\napp.use(Raven.errorHandler());\n\n// Optional fallthrough error handler\napp.use(function onError(err, req, res, next) {\n // The error id is attached to `res.sentry` to be returned\n // and optionally displayed to the user for support.\n res.statusCode = 500;\n res.end(res.sentry + '\\n');\n});\n\napp.listen(3000);\n