-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (29 loc) · 859 Bytes
/
app.js
File metadata and controls
34 lines (29 loc) · 859 Bytes
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
import express from 'express';
import bodyParser from 'body-parser';
import telegramBot from './services/telegram/index';
import sonarrHandler from './services/sonarr/index';
import * as http from 'http';
const PORT = 1337;
const server = express();
server.use(bodyParser.urlencoded({ extended: false }));
server.use(bodyParser.json());
/**
* Handle requests to Felicity server.
*
* @param {Object} req - Request object.
* @param {Object} res - Response object.
*/
server.post('/', (req, res) => {
const reqBody = req.body || {};
const fromSonarr = req.body.EventType === 'Download';
if (fromSonarr) {
sonarrHandler(reqBody);
res.sendStatus(200);
} else {
console.log('Felicity received and unhandled request type.');
}
});
server.listen(PORT, () => {
console.log(`Felicity is watching over port ${PORT}`);
});
telegramBot();