-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (29 loc) · 985 Bytes
/
index.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
require('dotenv').config();
const path = require('path')
const express = require('express');
const cors = require('cors');
const { dbConect } = require('./database/config');
// Crear el servidor de express
const app = express();
// Configurar CORS
app.use( cors() );
// Lectura y parseo del body
app.use( express.json() );
// Base de datos
dbConect();
//Directorio Público
app.use(express.static('public'))
// Rutas
app.use( '/api/usuarios', require('./routes/usuarios') );
app.use( '/api/hospitales', require('./routes/hospitales') );
app.use( '/api/medicos', require('./routes/medicos') );
app.use( '/api/todo', require('./routes/busquedas') );
app.use( '/api/login', require('./routes/auth') );
app.use( '/api/upload', require('./routes/uploads') );
//Finally
app.get('*', (req, res)=> {
res.sendFile(path.resolve (__dirname, 'public/index.html'))
})
app.listen( process.env.PORT, () => {
console.log('Servidor corriendo en puerto ' + process.env.PORT );
});