-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (28 loc) · 1016 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express');
const helmet = require('helmet');
const cors = require('cors');
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const api = require('./routes');
const server = express();
var Rollbar = require('rollbar');
var rollbar = new Rollbar({
accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
captureUncaught: true,
captureUnhandledRejections: true
});
server.use(express.json());
server.use(helmet());
server.use(cors({ origin: process.env.FRONTEND_URL, credentials : true}));
server.use(morgan('combined'));
server.use(express.urlencoded({ extended: false }));
server.use(cookieParser());
server.use((req, res, next) => {
// set default or minimum is 10 (as it was prior to v0.2.0)
if (req.query.limit <= 10) req.query.limit = 10;
next();
});
server.use('/api', api);
server.use(rollbar.errorHandler());
const PORT = process.env.PORT || 3300;
server.listen(PORT, () => console.log(`Server is live at http://localhost:${PORT}`));