-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.ts
54 lines (44 loc) · 1.96 KB
/
app.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
47
48
49
50
51
52
53
54
import express from 'express';
import { createUserRoutes } from './routes/user';
import { createAuthRoutes } from './routes/auth';
import { config } from './config/auth';
import cookieParser from 'cookie-parser';
import { createEventRoutes } from './routes/event';
import { createConfigRoutes } from './routes/config';
import { swaggerParams } from './config/swagger';
import { corsMiddleware } from './middlewares/corsMiddleware';
import { createTicketRoutes } from './routes/ticket';
import path from 'path';
import { createBaseRoutes } from './routes/base';
const app = express();
app.use(express.json());
app.use(cookieParser());
app.use(corsMiddleware());
// Configurar Swagger
app.use(
'/api-docs',
express.static('node_modules/swagger-ui-dist/', { index: false }),
swaggerParams.swaggerUI,
swaggerParams.swaggerSetup
);
// Serve the Swagger UI static assets (CSS, JS, etc.)
app.use('/api-docs', express.static(path.join(__dirname, 'node_modules/swagger-ui-dist')));
app.use('/api-docs/swagger-ui.css', express.static(path.join(__dirname, 'node_modules/swagger-ui-dist/swagger-ui.css')));
app.use('/api-docs/swagger-ui-bundle.js', express.static(path.join(__dirname, 'node_modules/swagger-ui-dist/swagger-ui-bundle.js')));
app.use('/api-docs/swagger-ui-standalone-preset.js', express.static(path.join(__dirname, 'node_modules/swagger-ui-dist/swagger-ui-standalone-preset.js')));
app.use('/api-docs/swagger-ui-init.js', express.static(path.join(__dirname, 'node_modules/swagger-ui-dist/swagger-ui-init.js')));
//Load Routes
app.use('/users', createUserRoutes());
app.use('/auth', createAuthRoutes());
app.use('/events', createEventRoutes());
app.use('/config', createConfigRoutes());
app.use('/tickets', createTicketRoutes());
app.use('/mint', createBaseRoutes());
app.get('/', (req, res) => {
//Response Json
res.json({ message: 'Hello we are BuildMyEvent' });
});
app.listen(config.port, () => {
console.log('Server is running on port 3000');
});
export default app;