-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·39 lines (33 loc) · 957 Bytes
/
app.js
File metadata and controls
executable file
·39 lines (33 loc) · 957 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
35
36
37
38
39
import dotenv from "dotenv";
import express from "express";
import swaggerUI from "swagger-ui-express";
import yamljs from "yamljs";
import dbConnect from "./config/dbConfig.js";
import MainController from "./controllers/MainController.js";
import authRouter from "./routes/auth.routes.js";
import productRouter from "./routes/product.routes.js";
import { BASE_API } from "./utils/constants.js";
dotenv.config();
dbConnect();
const app = express();
app.use(express.json());
app.use(
express.urlencoded({
extended: true,
})
);
const { home } = new MainController();
// On configure la documentation de l'API
const swaggerDefinition = yamljs.load("./swagger.yaml");
app.use(
BASE_API + "/docs",
swaggerUI.serve,
swaggerUI.setup(swaggerDefinition)
);
// ROUTES
// POST, GET, DELETE --> CRUD
app.use(BASE_API + "/products", productRouter);
// api/v1/user
app.use(BASE_API + "/user", authRouter);
app.use(BASE_API, home);
export default app;