-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathserver.js
43 lines (36 loc) · 787 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
37
38
39
40
41
42
43
const express = require('express');
// middleware
const helmet = require('helmet');
const RateLimit = require('express-rate-limit');
const limiter = new RateLimit({
windowMs: 15 * 60 * 1000,
max: 20,
delayMs: 0
});
const app = express();
// the rate limiter needs this if it's behind a reverse proxy
app.enable('trust proxy');
// use the middleware
app.use(helmet());
app.use(limiter);
const exec = require('child_process').exec;
app.get('/getId', (req, res) => {
exec('node getSessionId.js', (error, stdout) => {
let resObject;
if (error) {
resObject = {
ok: false,
error: error
};
} else {
resObject = {
ok: true,
sessionId: stdout
};
}
res.send(resObject);
});
});
app.listen(3000, () => {
console.log('Listening on port 3000');
});