-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
52 lines (45 loc) · 1.36 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
42
43
44
45
46
47
48
49
50
51
52
const express = require('express');
const app = express();
const winston = require('winston');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const config = require('./configuration/config.json');
const logger = () => {
const winstonLogger = new winston.Logger({
transports: [
new winston.transports.File({
level: 'debug',
filename: './endpoint_hits.log',
handleExceptions: true,
json: true,
maxsize: 5242880, // 5MB
maxFiles: 5,
colorize: true,
timestamp: true
}),
new winston.transports.Console({
level: 'debug',
handleExceptions: true,
json: false,
colorize: true,
timestamp: true
})
],
exitOnError: false
});
winstonLogger.stream = {
write: (message, encoding) => winstonLogger.info(message)
};
return morgan('dev', { stream: winstonLogger.stream });
}
const bootstrap = () => {
app.use(bodyParser.json());
app.listen(config.INTERNAL_PORT);
app.use(logger());
// Endpoint
app.post('/alexa', (req, res, next) => {
console.log('You called Alexa endpoint');
return res.status(200).send({});
});
};
bootstrap();