-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (28 loc) · 890 Bytes
/
app.js
File metadata and controls
34 lines (28 loc) · 890 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 studentRoutes from "./routes/student.route.js";
import authRoutes from "./routes/auth.route.js";
import bookRoutes from "./routes/book.route.js";
import cors from "cors";
import dotenv from "dotenv";
import cookieParser from "cookie-parser";
const app = express();
const corsOption = {
origin: ["http://localhost:3000"],
credentials: true,
};
dotenv.config();
app.use(express.json());
app.use(cookieParser());
app.use(express.urlencoded({ extended: true }));
app.use("/service/students", cors(corsOption), studentRoutes);
app.use("/service/auth", cors(corsOption), authRoutes);
app.use("/service/books", cors(corsOption), bookRoutes);
app.get("/", (req, res) => {
res.send({
message: "Dis is ma kingdom cum!",
});
});
let PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
console.log(`Server running on PORT: ${PORT}`);
});