Skip to content

Commit

Permalink
Added rollbar to app.js and #16
Browse files Browse the repository at this point in the history
Initial addition of [Rollbar](https://rollbar.com) to the application.
This baseline implementation adds a message upon server startup as well
as handling any uncaught exceptions.

- app.js - Added Rollbar with server side code from service. Added
  uncaught exception handler to log unexpected errors. Added code
  to link to Rollbar middleware.
  • Loading branch information
mnyon-grandkru committed Nov 1, 2015
1 parent 8fc121f commit 4f90ef2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ var config = require('./config'),
passport = require('passport'),
models = require('./models/index'),
helmet = require('helmet'),
rollbar = require("rollbar"),
csrf = require('csurf');

//create express app
var app = express();

// Rollbar initialization
rollbar.init("ba471954344648d490ea209ff586ae43");

// record a generic message and send to rollbar
rollbar.reportMessage("Rollbar started: " + Date.now());

//keep reference to config
app.config = config;

Expand All @@ -35,6 +42,19 @@ app.set('view engine', 'jade');
app.use(require('morgan')('dev'));
app.use(require('compression')());
app.use(require('serve-static')(path.join(__dirname, 'public')));

// Use the rollbar error handler to send exceptions to your rollbar account
app.use(rollbar.errorHandler('ba471954344648d490ea209ff586ae43'));

var options = {
// Call process.exit(1) when an uncaught exception occurs but after reporting all
// pending errors to Rollbar.
//
// Default: false
exitOnUncaughtException: true
};
rollbar.handleUncaughtExceptions("ba471954344648d490ea209ff586ae43", options);

app.use(require('method-override')());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Expand Down

0 comments on commit 4f90ef2

Please sign in to comment.