-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
72 lines (53 loc) · 1.45 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
64
65
66
67
68
69
70
71
72
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const port = 5555;
const router = require("express").Router()
const userRoute = require("./routers/user")
const authRoute = require("./routers/auth")
const addressRoute = require("./routers/address")
const adminRoute = require("./routers/admin")
const documentRoute = require("./routers/document")
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger/swagger.json');
dotenv.config();
/**
* Middleware that parses incoming requests with JSON payloads.
*/
app.use(express.json());
/**
* Connect to the MongoDB database using Mongoose.
*/
require('./db/mongoose');
/**
* Middleware that handles user-related routes.
*
*/
app.use("/api/user", userRoute);
/**
* Middleware that handles authentication-related routes.
*/
app.use("/api/auth", authRoute);
/**
* Middleware that handles address-related routes.
*/
app.use("/api/address", addressRoute);
/**
* Middleware that handles admin-related routes.
*/
app.use("/api/admin", adminRoute);
/**
* Middleware that handles document-related routes.
*/
app.use("/api/document", documentRoute);
/**
* Swagger Documentation Setup
*/
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
/**
* Start the Express server.
*/
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});