diff --git a/package.json b/package.json index 4fd9633..c6c1caa 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "express": "=4.14.0", "express-winston": "=2.1.2", "helmet": "=3.3.0", + "opbeat": "=4.4.0", "winston": "=2.3.0" }, "devDependencies": { diff --git a/server.js b/server.js index 9452082..1d0d241 100755 --- a/server.js +++ b/server.js @@ -6,6 +6,9 @@ const helmet = require('helmet'); const path = require('path'); const winston = require('winston'); const expressWinston = require('express-winston'); +const opbeat = require('opbeat').start({ + active: process.env.NODE_ENV === 'production' +}); const PORT = process.env.PORT || 5000; let SERVE_DIR; @@ -18,9 +21,6 @@ const PAGE_404 = path.join(SERVE_DIR, '.404.html'); const app = express(); -app.use(compression({ level: 9 })); -app.use(helmet()); - app.use(expressWinston.logger({ transports: [ new winston.transports.Console({ @@ -55,6 +55,10 @@ app.use(function (request, response, next) { }); +app.use(compression({ level: 9 })); +app.use(helmet()); +app.use(opbeat.middleware.express()); + const server = app.listen(PORT, function () { console.log('Server started on port ' + server.address().port); });