-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (28 loc) · 945 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
29
30
31
32
33
34
35
36
const express = require("express");
const dotenv = require("dotenv");
const connectDB = require("./api/config/db");
const app = express();
const bodyParser = require("body-parser");
const shiftRoutes = require("./api/routes/shiftRoutes");
const workerRoutes = require("./api/routes/workerRoutes");
const workerShiftRoutes = require("./api/routes/workShiftRoutes");
dotenv.config();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
//connect db
if (
process.env.NODE_ENV === "development" ||
process.env.NODE_ENV === "production"
) {
connectDB();
}
app.get("/", function (req, res) {
res.send("Hello World");
});
// Register routes
app.use("/api/v1/shift", shiftRoutes);
app.use("/api/v1/auth/worker", workerRoutes);
app.use("/api/v1/worker_shift", workerShiftRoutes);
const port = process.env.PORT;
app.listen(port, () => console.log(`Running on http://localhost:${port}`));
module.exports = app;