-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (34 loc) · 947 Bytes
/
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
const express = require("express");
const cors = require("cors");
const CONFIG = require("./config.js");
const STATUS = require("./routes/status");
const Startup = require("./features/startup.js");
const app = express();
// middleware
app.use(express.json());
app.use(cors());
// logging
app.use("/", (req, res, next) => {
console.log("Request: " + req.method + " " + req.url);
next();
});
// routes
const operator = require("./routes/operator");
app.use("/operator", operator);
const acc = require("./routes/acc");
app.use("/acc", acc);
const part = require("./routes/part");
app.use("/part", part);
const tag = require("./routes/tag");
app.use("/tag", tag);
const dummy = require("./routes/dummy");
app.use("/dummy", dummy);
// not found
app.get("*", (req, res) => {
res.send(STATUS.Bad("Page not found"));
});
// when server start
app.listen(CONFIG.PORT, () => {
console.log(`Listening on port ${CONFIG.PORT}!`);
Startup();
});