4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
1
|
// Modules ====================================================================
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
2
3
|
var express = require('express');
var app = express();
|
8ae24f57
Geoffrey PREUD'HOMME
Liste des membres
|
4
5
|
var mongoose = require('mongoose');
var morgan = require('morgan');
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
6
7
|
var bodyParser = require('body-parser');
var methodOverride = require('method-override');
|
8bb442a5
Geoffrey PREUD'HOMME
Possibilité de se...
|
8
|
var cookieParser = require('cookie-parser')
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
9
|
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
10
|
// Application ================================================================
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
11
|
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
12
13
|
var port = process.env.PORT || 8080;
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
14
15
|
// Connection à la BDD
var db = require('./config/db');
|
8ae24f57
Geoffrey PREUD'HOMME
Liste des membres
|
16
|
mongoose.connect(db.url);
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
17
|
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
18
|
// Tricks
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
19
|
app.use(bodyParser.json());
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
20
21
22
|
app.use(bodyParser.json({
type: 'application/vnd.api+json'
}));
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
23
24
25
|
app.use(bodyParser.urlencoded({
extended: true
}));
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
26
27
|
app.use(methodOverride('X-HTTP-Method-Override'));
|
8bb442a5
Geoffrey PREUD'HOMME
Possibilité de se...
|
28
29
30
|
// Cookie-parser
app.use(cookieParser())
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
31
|
// Dossier public
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
32
33
|
app.use(express.static(__dirname + '/public'));
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
34
35
|
// Routes
require('./app/routes')(app);
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
36
|
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
37
38
|
app.listen(port);
|
4932caf3
Geoffrey PREUD'HOMME
Nettoyage et rebr...
|
39
|
console.log('La magie du CI se passe au port ' + port);
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
40
|
|
894b21fa
Geoffrey PREUD'HOMME
Application MEAN ...
|
41
|
exports = module.exports = app;
|