-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (34 loc) · 1.09 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
// Carregando módulos
const express = require('express')
const handlebars = require('express-handlebars')
const app = express()
const cors = require('cors')
const index = require('./routes/index')
const apiBlip = require('./routes/apiBlip')
const path = require('path')
const mongoose = require('mongoose')
// Configurações
// bodyParser
app.use(express.urlencoded({extended: true}))
app.use(express.json())
app.use(cors())
// Handlebars
app.engine('handlebars', handlebars({defaultLayout: 'main'}))
app.set('view engine', 'handlebars')
// Mongoose
mongoose.Promise = global.Promise
mongoose.connect(process.env.DB_CONNECT, {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log('Conectado')
}).catch((err) => {
console.log(err)
})
// Public
app.use(express.static(path.join(__dirname, 'public')))
// Rotas
app.use('/', index)
app.use('/', apiBlip)
// Outros
app.listen(process.env.PORT)