-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
39 lines (32 loc) · 1.05 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
const express = require("express");
const bodyParser = require("body-parser");
const db = require("./config/db");
require("dotenv").config();
const path = require("path");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cors({
origin: ["http://localhost:3000", "http://localhost:5500"],
credentials: true,
}));
const adminRouter = require("./routes/admin_router");
const utilitiesRouter = require("./routes/utilities_route");
const complaintRouter = require("./routes/complaint_route");
//express serve public folder as static
app.use(express.static(path.join(__dirname, "public")));
app.get("/", (req, res) => {
res.send("Hello from kwa-backend server!");
});
app.use("/api/v2", adminRouter);
app.use("/api/v2", utilitiesRouter);
app.use("/api/v2", complaintRouter);
db.sync().then(() => {
app.listen(3000, () => {
console.log("Server started on port 3000");
});
});