-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 847 Bytes
/
index.js
File metadata and controls
34 lines (29 loc) · 847 Bytes
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
import express from "express";
import cors from "cors";
import dotenv from "dotenv";
import MemberRoutes from "./Source/Routes/MemberRoutes.js";
import BookRoutes from "./Source/Routes/BooksRoutes.js";
import LoanRoutes from "./Source/Routes/LoanRoutes.js";
import specs from "./Source/swagger.js";
import swaggerUi from "swagger-ui-express";
dotenv.config();
const app = express();
// declared swagger docs
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(specs));
app.get("/api/docs", (req, res) => {
res.redirect("/api-docs");
});
app.use(express.json());
app.use(
cors({
credentials: true,
origin: "http://localhost:3000",
})
);
// route app
app.use(MemberRoutes);
app.use(BookRoutes);
app.use(LoanRoutes);
app.listen(process.env.APP_PORT, () => {
console.log(`Server up and running... ${process.env.APP_PORT}`);
});