-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (35 loc) · 1.05 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
'use strict';
var config = {
port: process.env.PORT || 3005,
getResponseText: process.env.GETTEXT || 'Hello',
maxBodySize: process.env.MAX_BODY_SIZE || '50mb', // See all valid formats in: https://www.npmjs.com/package/bytes
};
var _ = require('lodash');
var app = require('express')();
var server = require('http').Server(app);
// Express configuration
app.use(require('body-parser').json({limit: config.maxBodySize}));
// Socket initialization
const io = require('socket.io')(server, {
serveClient: false
});
io.on('connection', function (socket) {
console.log('new client connected');
});
// Sent validator as required by Meraki
app.get('*', function (req, res) {
res.status(200).send(config.getResponseText);
});
// Receive notifications
app.post('*', function (req, res) {
console.log(req.path);
io.emit('post', {
path: req.path,
body: req.body
});
res.status(200).send();
});
// Start server
server.listen(config.port, function () {
console.log('Server listening on port ' + config.port);
});