-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.js
45 lines (39 loc) · 1.22 KB
/
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
43
44
45
var express = require('express');
var bodyParser = require('body-parser')
//var cors = require('cors');
var morgan = require('morgan');
var methodOverride = require('method-override');
var compression = require('compression');
var routes = require('./server/routes');
var app = express();
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }))
// parse application/json
app.use(bodyParser.json());
// compress all responses
app.use(compression());
// Lets you use HTTP verbs such as PUT or DELETE in places where the client doesn’t support it.
app.use(methodOverride());
// HTTP request logger middleware for node.js
app.use(morgan('dev'));
// enable all CORS requests
// app.use(cors());
// App routes
app.use(routes(express.Router()));
// Static files
app.use(express.static(__dirname + '/public'));
// Models of the server
var models = require('./server/models');
models.sequelize
.authenticate()
.then(function() {
console.log('Connection successful');
})
.catch(function(error) {
console.log('Error creating connection');
});
// Listen server
app.set('port', process.env.PORT || 3000);
app.listen(app.get('port'), function() {
console.log('Listen server');
});