archive
/
tstatic
Archived
1
Fork 0

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-winston": "=2.1.2",
"helmet": "=3.3.0",
"opbeat": "=4.4.0",
"winston": "=2.3.0"
},
"devDependencies": {

View File

@ -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);
});