-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
77 lines (77 loc) · 2.33 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
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
var express = require("express");
var request = require("request");
var app = express();
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
next();
});
app.get("/global", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
app.get("/global-sembuh", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/sembuh" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
app.get("/global-meninggal", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/meninggal" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
app.get("/global-positif", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/positif" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
app.get("/nasional", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/indonesia" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
app.get("/provinsi", function (req, res) {
request(
{ url: "https://api.kawalcorona.com/indonesia/provinsi" },
function (error, response, body) {
if (error || response.statusCode !== 200) {
return res.status(500).json({ type: "error", message: err.message });
}
res.json(JSON.parse(body));
}
);
});
var PORT = process.env.PORT || 5000;
app.listen(PORT, function () {
return console.log("listening on " + PORT);
});