-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
94 lines (88 loc) · 2.6 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const express = require("express");
var getTime = require("date-fns/getTime");
const bodyParser = require("body-parser");
const path = require("path");
const app = express();
app.use(express.static(path.join(__dirname, "build")));
app.get("/", function(req, res) {
res.sendFile(path.join(__dirname, "build", "index.html"));
});
app.get("/api/getList", (req, res) => {
let start = Number(req.query.start);
let finish = Number(req.query.finish);
var data = [
{
id: "ee3c0801-9609-49ea-87fa-fcb9b9f438b9",
launch_date: "2019-08-23 00:00:00",
title: "Black Is The New Orange: Season 1"
},
{
id: "01ddcfb6-9be0-4d99-a6e3-6b17ee37ac97",
launch_date: "2018-08-14 00:00:00",
title: "Black Is The New Orange: Season 2"
},
{
id: "6761271c-958f-49ef-bc1a-8f8022d24d11",
launch_date: "2019-08-28 00:00:00",
title: "Cathunter: Season 2"
},
{
id: "8761273c-958f-49ef-bc1a-9f8022d24d11",
launch_date: "2019-08-24 00:00:00",
title: "Black Is The New Orange: Season 3"
},
{
id: "1761253c-958f-49ef-bc1a-9f6022d24d11",
launch_date: "2019-08-24 12:00:00",
title: "Planet Mars: Season 1"
},
{
id: "789f7d37-b43d-4fd0-b169-6745cd103d25",
launch_date: "2018-03-14 00:00:00",
title: "Strangest Things: Season 1"
},
{
id: "8fa94004-414f-4eed-bb0e-45a2b10ebebf",
launch_date: "2018-05-27 00:00:00",
title: "Strangest Things: Season 2"
},
{
id: "0d413a7a-b776-44d5-9235-19602346f94a",
launch_date: "2018-06-12 00:00:00",
title: "House of Cats: Season 1"
},
{
id: "65a208a5-768b-4677-838f-33c4dd385f9f",
launch_date: "2018-07-01 00:00:00",
title: "House of Cats: Season 2"
},
{
id: "585a9285-d411-4625-a3f5-357f3e554673",
launch_date: "2018-08-11 00:00:00",
title: "Brighter"
},
{
id: "3adad7b8-da99-4aba-b4f1-df43d3d9d7cf",
launch_date: "2019-08-01 00:00:00",
title: "Sandy Waxer"
},
{
id: "e0986a67-d23a-415d-88d8-935de948ad16",
launch_date: "2018-12-12 00:00:00",
title: "Dave Chapel Stand-up Special"
},
{
id: "5d3a0f27-d422-4629-ac5a-84732e248be5",
launch_date: "2018-01-01 00:00:00",
title: "The Adventures of Potato"
}
];
var filteredData = data.filter(function(item) {
var launchDate = new Date(item.launch_date);
var launchDateTime = getTime(launchDate);
var check = launchDateTime > start && launchDateTime < finish;
return check;
});
res.json(filteredData);
});
app.listen(process.env.PORT || 8080);