-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
28 lines (22 loc) · 876 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
import express from "express";
import dotenv from "dotenv";
import { dbConnection } from "./database/dbConnection.js";
import { errorMiddleware } from "./middlewares/error.js";
import userRouter from "./routes/userRouter.js";
import fileRouter from "./routes/fileRoute.js";
import booksRoute from "./routes/BooksRoute.js"
import cookieParser from "cookie-parser";
const app = express();
dotenv.config({path:"./config/config.env"})
// cookieparser used for getting token and authorization
app.use(cookieParser());
// express json converts string into json
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use("/api/v1/user", userRouter);
app.use("/api/v1/file", fileRouter);
app.use("/api/v1/books", booksRoute);
dbConnection();
// Always use error middleware at last
app.use(errorMiddleware)
export default app;