-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
38 lines (29 loc) · 920 Bytes
/
server.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
30
31
32
33
34
35
36
37
38
import TestConsumer from './Http/Consumer/test.consumer.js';
import Logger from './Logger/Logger.js';
import router from './routes/api.js';
import express from 'express';
import cors from 'cors';
import { json } from 'express';
const APP = express();
const PORT = process.env.SERVER_PORT || 3000;
// Inicializar logger
Logger();
// Configurar Express
APP.use(json());
APP.use(cors());
// Inicializar el pool de conexiones antes de iniciar el servidor
async function startServer() {
try {
// Inicializar el cliente global
await global.DB.connect();
// Configurar rutas
APP.use('/api', router);
// Iniciar servidor Express
APP.listen(PORT, () => {
TestConsumer();
});
} catch (err) {
console.error('Error al iniciar el servidor:', err);
}
}
startServer();