-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
42 lines (35 loc) · 926 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
// List module dependancies
var express = require('express')
const cors = require('cors')
var bodyParser = require('body-parser')
var http = require('http')
var db = require('./models')
var middlewares = require('./ressources/middlewares')
// Init express app
var app = express()
// Init all dependencies used by the app
app.use(bodyParser.json())
app.use(
bodyParser.urlencoded({
extended: false,
}),
)
process.env.NODE_ENV = 'development'
// Init Databases
if (process.env.NODE_ENV == 'development') {
app.use(
cors({
origin: '*',
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
exposedHeaders: ['Content-Range', 'X-Content-Range'],
}),
)
//db.sequelize.sync({ force: false })
}
// Init REST ressources
require('./ressources').initialize(app)
// start server
var port = process.env.PORT_MANGAL_API || 3004
server = http.createServer(app)
server.listen(port)
module.exports = server