-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
41 lines (33 loc) · 1.03 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
const express = require('express');
const cors = require('cors');
const landing = require('./middlewares/landingTemplate');
const extractTitle = require('./middlewares/extractTitle');
const manifest = require('./data/manifest');
const mapToStremioSubs = require('./middlewares/sendMappedSubs');
const getWizdomSubs = require('./middlewares/getWizdomSubs');
const errorHandler = require('./middlewares/errorMiddleware');
const sendSrt = require('./middlewares/sendSrt');
const addon = express();
addon.use(cors());
//Landing page request.
addon.get('/', landing);
//manifest request.
addon.get('/manifest.json', function (req, res) {
res.send(manifest);
});
//Addon's readme request
addon.get('/README.md', (req, res) => {
res.sendFile(`${__dirname}/README.md`);
});
//Subtitles request.
addon.get('/subtitles/:type/:imdbId/:query?.json', [
extractTitle,
getWizdomSubs,
mapToStremioSubs,
]);
/**
* unzips Wizdom zip files and send the srt file in it.
*/
addon.get('/srt/:id.srt', sendSrt);
addon.use(errorHandler);
module.exports = addon;