-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (29 loc) · 997 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
require('dotenv').config()
const express = require('express')
const cors = require('cors')
const path = require('path')
const { dbConnection } = require('./db/config.js')
// Crear el servidor de express
const app = express()
// Config cors
app.use(cors())
// Lectura y parseo del body
app.use(express.json())
// Conectar a la base de datos
dbConnection()
// Directorio público
app.use(express.static('public'))
// Rutas
app.use('/api/usuarios', require('./routes/usuarios.js'))
app.use('/api/hospitales', require('./routes/hospitales.js'))
app.use('/api/medicos', require('./routes/medicos.js'))
app.use('/api/login', require('./routes/auth.js'))
app.use('/api/todo', require('./routes/busquedas.js'))
app.use('/api/upload', require('./routes/uploads.js'))
// Any route not found
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'public/index.html'))
})
app.listen(process.env.PORT, () => {
console.log(`Server corriendo en: http://localhost:${process.env.PORT}`)
})