-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
36 lines (31 loc) · 848 Bytes
/
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
'use strict';
const express = require('express');
const winston = require('winston');
// Constants
const PORT = 8000;
const HOST = '0.0.0.0';
// log file on linux platforms
if (process.platform !== 'win32') {
try {
winston.add(winston.transports.File, { filename: '/var/log/eb-worker-docker-nodejs/app.log' });
} catch (err) {
winston.error('winston file transport error : ', err);
}
}
// ROUTING
const app = express();
app.get('/', (req, res) => {
winston.info('[GET]/');
res.send('Server Running\n');
});
app.post('/', (req, res) => {
winston.info('[POST]/');
res.send('Message received\n');
});
app.post('/scheduled', (req, res) => {
winston.info('[POST]/scheduled');
res.send('Scheduled CRON done\n');
});
// START
app.listen(PORT, HOST);
winston.info('Running on http://%s:%s', HOST, PORT);