-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.js
More file actions
43 lines (34 loc) · 1016 Bytes
/
dev.js
File metadata and controls
43 lines (34 loc) · 1016 Bytes
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
require('dotenv').load()
const path = require('path')
const express = require('express')
const app = express()
const cors = require('cors')
const bodyParser = require('body-parser')
const http = require('http').Server(app)
const Sequelize = require('sequelize')
const passport = require('passport')
const configureApi = require('./api/v1')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(passport.initialize())
app.use(cors())
const db = new Sequelize(process.env.DATABASE_URL, {
dialect: 'postgres',
logging: false
})
const models = db.import(__dirname + '/models')
Object.keys(models)
.map(name => models[name])
.filter(model => model.associate)
.forEach(model => model.associate(models))
db.sync()
const port = process.env.PORT || 3030
http.listen(port, function() {
console.log(`Listening on port ${port}`)
})
const apiOptions = {
app: app,
models: models,
passport: passport
}
configureApi(apiOptions)