forked from aceleradora-TW/prescare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (37 loc) · 1.12 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
38
39
40
41
42
43
44
const express = require('express')
const bodyParser = require('body-parser')
const expressLayouts = require('express-ejs-layouts')
const ejs = require('ejs')
const Sequelize = require('sequelize')
const routesInitializer = require('./src/routes')
const modelsInitializer = require('./src/models')
const tabelaFarmaceutica = require('./src/mocks/tabelaFarmaceutica')
const settings = require('./settings')
const app = express()
const databaseConnection = new Sequelize(settings.DATABASE_URL, {
dialect: 'postgres',
define: {
underscored: true,
timestamps: false,
}
})
const models = modelsInitializer(databaseConnection)
const routes = routesInitializer(models)
const startApplication = () => {
app
.use(expressLayouts)
.use(express.static(__dirname + '/public/'))
.use(bodyParser.urlencoded({
extended: false
}))
.set('view engine', 'ejs')
.set('views/pages', 'tabela-abas')
.use('/', routes)
.listen(settings.PORT, () =>
console.log('Servidor iniciado em http://localhost:' + settings.PORT)
);
}
databaseConnection
.sync()
.then(startApplication)
.catch(console.log)