forked from kontur-web-courses/async
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (40 loc) · 1.13 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
const express = require("express");
const getBuh = require("./data/buh");
const getAnalytics = require("./data/analytics");
const getReqBase = require("./data/reqBase");
const app = express();
const port = 3000;
const ORGS_LIST = [
"1027700092661",
"1026605606620",
"1027700070518",
"1037739877295",
"1106659003769",
"1130280036040",
"1026604939855",
"1115000005614",
"1106659013658",
"1027402166835",
];
app.use(express.static("static"));
app.listen(port, (err) => {
if (err) {
return console.log("something bad happened", err);
}
console.log(`server is listening on http://localhost:${port}`);
});
app.get("/orgsList", (request, response) => {
response.json(ORGS_LIST);
});
app.get("/api3/:path", (request, response) => {
const reqParam = request.params.path;
if (reqParam === "buh") {
response.send(getBuh(request.query));
} else if (reqParam === "analytics") {
response.send(getAnalytics(request.query));
} else if (reqParam === "reqBase") {
response.send(getReqBase(request.query));
} else {
response.status(404).send();
}
});