-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
44 lines (34 loc) · 1.25 KB
/
index.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
const express = require("express");
const cors = require("cors");
const app = express();
const port = 3180;
app.use(cors());
const scrapeCity = require('./src/city');
const scrapePlaying = require('./src/playing');
const scrapeUpcoming = require('./src/upcoming');
const scrapeTeater = require('./src/theaters');
const scrapeSchedules = require('./src/schedule');
const scrapeMovies = require('./src/movies');
app.get("/cineplex/city", async (req, res) => {
const cities = await scrapeCity();
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({cities}, null, 2));
});
app.get("/cineplex/playing", async (req, res) => {
const playing = await scrapePlaying();
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({playing}, null, 2));
});
app.get("/cineplex/upcoming", async (req, res) => {
const upcoming = await scrapeUpcoming();
res.setHeader('Content-Type', 'application/json');
res.send(JSON.stringify({upcoming}, null, 2));
});
app.use("/cineplex/theaters", scrapeTeater);
app.use("/cineplex/schedule", scrapeSchedules);
app.use("/cineplex/movies", scrapeMovies);
app.listen(port, () => {
console.log(
`Jadalak API service [cineplex] listening at http://localhost:${port}/cineplex/`
);
});