-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
34 lines (30 loc) · 991 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
const express = require('express')
const app = express()
const path = require('path')
const hbs = require('hbs')
const db = require('./database/controller')
const sesion = require('./extras/sessions')
//CONFIGURATIONS
app.set('view engine', 'hbs');
app.set('views', path.join(__dirname, './views'))
hbs.registerPartials(path.join(__dirname, './views/partials'))
app.use(express.urlencoded({ extended: false }))
app.use(express.json({ limit: '100mb' }))
app.use(sesion)
require('./extras/helpers')
app.use(express.static(path.join(__dirname, './assets')))
app.use(require('./routes/index'))
const port = process.env.PORT || 3000
app.listen(port, () => {
console.log(`[SERVER]: Starting server ${port}`)
})
.on('listening', () => {
console.log(`[SERVER]: Server started ${port}.`)
})
.on('error', (err) => {
console.log(`[SERVER]: Error trying to start the server on ${port}.`)
console.log(err)
})
.on('close', () => {
console.log(`[SERVER]: The server was closed.`)
})