Add opbeat middleware

This commit is contained in:
Jake Howard 2017-01-12 17:19:42 +00:00
parent ba8488164f
commit d7c70012e5
2 changed files with 8 additions and 3 deletions

View file

@ -30,6 +30,7 @@
"express": "=4.14.0", "express": "=4.14.0",
"express-winston": "=2.1.2", "express-winston": "=2.1.2",
"helmet": "=3.3.0", "helmet": "=3.3.0",
"opbeat": "=4.4.0",
"winston": "=2.3.0" "winston": "=2.3.0"
}, },
"devDependencies": { "devDependencies": {

View file

@ -6,6 +6,9 @@ const helmet = require('helmet');
const path = require('path'); const path = require('path');
const winston = require('winston'); const winston = require('winston');
const expressWinston = require('express-winston'); const expressWinston = require('express-winston');
const opbeat = require('opbeat').start({
active: process.env.NODE_ENV === 'production'
});
const PORT = process.env.PORT || 5000; const PORT = process.env.PORT || 5000;
let SERVE_DIR; let SERVE_DIR;
@ -18,9 +21,6 @@ const PAGE_404 = path.join(SERVE_DIR, '.404.html');
const app = express(); const app = express();
app.use(compression({ level: 9 }));
app.use(helmet());
app.use(expressWinston.logger({ app.use(expressWinston.logger({
transports: [ transports: [
new winston.transports.Console({ 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 () { const server = app.listen(PORT, function () {
console.log('Server started on port ' + server.address().port); console.log('Server started on port ' + server.address().port);
}); });