forked from Igire-Rwanda/Transport-Tech-bn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (51 loc) · 1.74 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import express from "express";
import dotenv from "dotenv";
import cors from "cors";
// import test from "./controllers/test.js";
import Homepage from "./controllers/homepage.js";
import routes from "./routes/routes.js";
import vehicle from "./routes/vehicles.js";
import booking from "./routes/booking-seats.js";
import roleAssignment from "./routes/role-assignment.js";
import user from "./routes/users.js";
import status from "./routes/actStatusRoute.js"
import createGps from "./routes/gpsRoutes.js";
import address from "./routes/address.js";
import mongoose from "mongoose";
import messageRoutes from "./routes/messageRoutes.js";
import registrationRouter from "./routes/registrationRouter.js";
import seatRoutes from "./routes/markseat.js";
dotenv.config();
const connectMongo = () => {
mongoose
.connect(process.env.MONGODB_LINK)
.then(() => {
console.log("Database Connected successfully");
})
.catch((error) => {
console.log("Failed to connect to database ", error);
});
};
const app = express();
app.use(express.json());
app.use(cors());
// app.use("/api/v2", user);
app.get("/", Homepage)
app.use("/api/v2/vehicles", vehicle);
app.use("/api/v2/booking", booking);
app.use("/api/v2/routes", routes);
app.use("/api/v2/role", roleAssignment);
app.use("/api/v2/status", status);
app.use("/api/v2/gps2", createGps);
app.use("/api/v2/messages",messageRoutes);
app.use("/api/v2/address", address);
app.use("/api/v2/user", user);
app.use("/api/v2/messages", messageRoutes);
app.use("/api/v2/register", registrationRouter);
app.use("/api/v2/seats", seatRoutes); // seat marked as served
app.use("/server", routes);
const port = 5000;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
connectMongo();
});