-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.ts
46 lines (38 loc) · 1.52 KB
/
server.ts
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
42
43
44
45
46
import express from "express";
import { config } from "dotenv";
import dbConnection from "./db/dbConnection";
import cors from "cors";
import authRouter from "./authentication/route/authRoute";
import userRouter from "./users/route/userRoute";
import categoryRouter from "./categories/route/categoryRoute";
import eventRouter from "./events/route/eventRoute";
import swaggerUi from "swagger-ui-express";
import swaggerSpec from "./swaggerConfiguration/config";
import cloudinaryRouter from "./cloudinary/route/cloudinaryRoute";
import orderRouter from "./orders/route/orderRoute";
import paymentRouter from "./payment/route/paymentRoute";
import ticketRouter from "./ticket/route/ticketRoute";
config();
const PORT = Number(process.env.PORT) ?? 3000;
const HOST = process.env.HOST!;
const app = express();
app.use(express.json());
app.use(cors({
origin: '*',
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
allowedHeaders: ['Content-Type', 'Authorization', 'token', 'ngrok-skip-browser-warning']
}));
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec));
app.use('/auth', authRouter);
app.use("/user", userRouter);
app.use("/category", categoryRouter);
app.use("/event", eventRouter);
app.use("/image", cloudinaryRouter);
app.use("/order", orderRouter);
app.use("/pay", paymentRouter);
app.use("/ticket", ticketRouter);
dbConnection();
app.listen(PORT, HOST, () => {
console.log(`Server is running on http://${HOST}:${PORT}`);
console.log(`Documentación disponible en http://${HOST}:${PORT}/api-docs`);
})