-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (28 loc) · 881 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
43
import express from 'express';
import router from './routes/index.js';
import db from './config/db.js'
const app = express();
//Conectar a la base de datos
db.authenticate()
.then(() => console.log("Base de datos conectada"))
.catch(error => console.log(error))
//definir puerto
const port = process.env.PORT || 4000;
//habilitar PUG
app.set('view engine','pug')
//Obtener el año actual
app.use( (req,res,next)=> {
const year = new Date()
res.locals.actualYear = year.getFullYear();
res.locals.nombreSitio = "Agencia de Viajes"
return next()
})
//agregar body Parcer para leer datos del formulario
app.use(express.urlencoded({extended:true}))
//agregar la carpeta publica
app.use(express.static('public'));
//agregar routers
app.use('/',router)
app.listen(port, () => {
console.log(`El servidor esta funcionando el el puerto ${port}`)
})