-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
41 lines (34 loc) · 1.11 KB
/
server.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
33
34
35
36
37
38
39
40
41
'use strict';
require('dotenv').config();
let join = require('path').join;
let express = require('express');
let winston = require('winston');
let requestLogger = require('./app/middlewares/request-logger');
let cors = require('./app/middlewares/cors');
let bodyParser = require('body-parser');
let errorHandler = require('./app/middlewares/error-handler');
let setCredentials = require('./app/middlewares/set-credentials');
let clientContext = require('./app/middlewares/client-context');
let Routes = require('./app/routes');
const port = process.env.PORT || 8080;
const app = express();
winston.configure({
transports: [
new winston.transports.File({
json: true,
filename:'/dev/stdout'
})
],
exitOnError: false
});
app.use(requestLogger);
app.use(bodyParser.json({ type: 'application/json' }));
app.use(cors);
app.use('/save-client/:clientKey', require('./app/controllers/save-client'));
app.use(clientContext);
app.use('/google-api/*', setCredentials);
app.use(Routes);
app.use(errorHandler);
app.listen(port, function () {
winston.info('Server listening on port: ' + port, {});
});