-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (34 loc) · 893 Bytes
/
app.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
import express from "express";
import dotenv from "dotenv";
import cors from "cors";
import connectDB from "./config/db.config.js";
import cookieParser from "cookie-parser";
import userRouter from "./routes/userRoutes.js";
import fileRouter from "./routes/fileRoutes.js";
import morgan from "morgan";
dotenv.config();
const app = express();
const port = process.env.PORT || 3000; // Default to port 3000 if not set in environment
app.use(express.json());
app.use(cookieParser());
app.use(
express.urlencoded({
extended: true,
})
);
app.use(
cors({
origin: "http://localhost:5173",
credentials: true,
})
);
app.use(morgan('dev'));
connectDB();
app.use("/api/v1/user", userRouter);
app.use("/api/v1/file", fileRouter);
app.get("/", (req, res) => {
res.send("Hello World");
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});