-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
50 lines (37 loc) · 1.05 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//variabes de entorno
const dotenv = require("dotenv");
//requerimientos e imports
const express = require('express');
const cors = require('cors');
const logger = require('morgan');
const { error404Handler, errorHandler } = require('./middleware');
//requerimientos propios
const { dbConnection } = require('./config/database');
const { swConfig } = require('./config/swagger');
const routes = require('./routes/index');
const config = require("config");
//settings
dotenv.config();
// Creando servidor de express
const app = express();
//configurar CORS
app.use(cors());
//Lectura y Parseo del body
app.use( express.json());
app.use(express.urlencoded({ extended: false }));
//log
app.use(logger(config.get('logger')));
//Base de Datos
dbConnection();
//swagger
swConfig();
//directorio publico
// app.use(express.static('public'));
// app.set("port", config.general.port || 8080);
// app.set("sport", config.general.sport || 8443);
//Rutas
app.use('/', routes);
//captura de errores de http
app.use(error404Handler);
app.use(errorHandler);
module.exports = app;