forked from prakasmishra/Library-Management-system
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
56 lines (38 loc) · 1.47 KB
/
Copy pathapp.js
File metadata and controls
56 lines (38 loc) · 1.47 KB
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
import express from "express";
import connectToDB from "./db/connectToDB.js";
import cors from "cors";
import checkRoutes from "./routes/checkRoutes.js";
import adminRoutes from "./routes/adminRoutes/adminRoutes.js";
import commonRoutes from "./routes/commonRoutes/commonRoutes.js";
import myBooksRoutes from "./routes/userRoutes/myBooks/myBooksRoutes.js";
import booksRoutes from "./routes/userRoutes/books/booksRoutes.js";
import profileRoutes from "./routes/userRoutes/profileRoutes/profile.js";
import addDetailsRoutes from "./routes/userRoutes/authentication/auth.js";
import { errorHandler, notFound } from "./middlewares/errorMiddleware.js";
const app = express();
app.use(cors());
const PORT = process.env.PORT;
app.use(express.json());
// Routes
app.use("/api/developer", checkRoutes);
// user
app.use("/api/user/myBooks", myBooksRoutes);
app.use("/api/user/books", booksRoutes);
app.use("/api/user/profile", profileRoutes);
app.use("/api/user/auth", addDetailsRoutes);
//user/book/browse
// admin
app.use("/api/admin", adminRoutes);
// common for search books
app.use("/api/common", commonRoutes);
import someRoute from './demo/someRoute.js';
app.use('/api/demo',someRoute);
app.use(notFound);
app.use(errorHandler);
import { attachAdminSocket } from "./sockets/admin.js";
const adminSocketServer = attachAdminSocket(app);
adminSocketServer.listen(PORT, () => {
connectToDB();
const d = new Date();
console.log(`Server listening on port http://localhost:${PORT} on ${d}`);
});