-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
29 lines (28 loc) · 1.13 KB
/
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
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const fs = require("fs");
const swaggerUi = require("swagger-ui-express");
const swaggerDocument = require("./src/Swagger/swagger.json");
const customCss = fs.readFileSync(process.cwd() + "/src/Swagger/swagger.css", "utf8");
const usersRoute = require("./src/Routes/Users/users.routes");
const productsRouter = require("./src/Routes/Products/products.routes");
const mediaRouter = require("./src/Routes/Media/media.routes");
const cartRouter = require("./src/Routes/Cart/cart.routes");
const { connect } = require("./src/Config/db.config");
const PORT = process.env.PORT;
const app = express();
app.use(cors());
app.use(express.json());
app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument, { customCss }));
app.use("/api/products", productsRouter);
app.use("/api/medias", mediaRouter);
app.use("/api/users", usersRoute);
app.use("/api/cart", cartRouter);
app.get("/", (req, res) => {
res.send(`<h1>API Works !!!</h1>`);
});
app.listen(PORT || 9000, async () => {
await connect();
console.log(`Server Started Listening On PORT ${PORT}`);
});