server.js
926 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
// Modules ====================================================================
var express = require('express');
var app = express();
var mongoose = require('mongoose');
var morgan = require('morgan');
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
// Application ================================================================
var port = process.env.PORT || 8080;
// Connection à la BDD
var db = require('./config/db');
mongoose.connect(db.url);
// Tricks
app.use(bodyParser.json());
app.use(bodyParser.json({
type: 'application/vnd.api+json'
}));
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(methodOverride('X-HTTP-Method-Override'));
// Dossier public
app.use(express.static(__dirname + '/public'));
// Routes
require('./app/routes')(app);
app.listen(port);
console.log('La magie du CI se passe au port ' + port);
exports = module.exports = app;