-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (21 loc) · 715 Bytes
/
app.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
const express = require("express");
const api = require("./controllers/routes");
const constants = require("./helpers/constants");
const app = express();
const PORT = process.env.PORT || 80;
const HOST = process.env.HOST || "http://localhost"
app.use([express.json(), express.urlencoded({extended: true})]);
app.use("/api", api);
app.get("/", (_, res)=>{
res.status(200).send(constants.root);
});
app.get("/about", (_, res)=>{
res.status(200).send(constants.about);
});
app.get("/reference", (_, res)=>{
res.status(200).send(constants.api_urls);
});
app.get("*", (_, res)=>{
res.status(404).send(constants[404]);
});
app.listen(PORT, () => {console.log("Server is listening at %s", HOST);});