-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
51 lines (39 loc) · 1.04 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
'use strict';
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const Listener = require('./listener');
const appServer = express();
appServer.use(
bodyParser.json(
{
limit: '6mb'
}
)
);
appServer.use(express.static('public'));
appServer.use('/node_modules', express.static('node_modules'));
appServer.post(
'/start-listening',
function (req, res) {
let sourcePath = req.body.sourcePath;
let destPath = req.body.destinationPath;
let startResult = Listener.StartListen(sourcePath, destPath);
if (true !== startResult) {
return res.status(501).end(startResult);
}
return res.end();
}
);
appServer.get(
'/stop-listening',
function (req, res) {
if (!Listener.StopListen()) {
return res.status(501).end();
}
return res.end();
}
);
appServer.listen(3333, function () {
console.log('listening at port: ' + 3333);
});