forked from huiledecode/OTF-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
executable file
·91 lines (78 loc) · 2.6 KB
/
app.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*******************************************************************************
* Date : 11/06/2014
* OBJET: Réalisation d'un Framework de routage générique sur Express 4.X avec
* gestion des exeptions, de l'authentification et template Handlebars.
*
* author : Stéphane Mascaron && Eric Papet
*
******************************************************************************/
//--
//--
//--
// Expres 4.2 midleware
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var bodyParser = require('body-parser');
var flash = require('express-flash');
var secret = GLOBAL.config["SESSION"].secret || '7m62cnP9rgVh7hH9NyUAdRNwTSHWDsfWFLeMMD7n4vUEuREJtyWbfzsTMFSeqzmYnng6CRd4yBYTCesJdDkNX4SjDmYWqZLcSscHw5Nh256b4wWjdjSdxr7rrsAU7RWZ"';
var cookie_name = GLOBAL.config["SESSION"].cookie_name || 'connect.sid';
//--
// Express Configuration
var app = express();
//var app;
//--
// view engine setup
require('./otf_core/lib/otf_viewer')(app);
//--
// favicon
app.use(favicon(__dirname + '/public/favicon/favicon.ico'));
//--
// Dev Logger
if (GLOBAL.config["ENV"].mode === 'DEV') {
var logger = require('morgan');
app.use(logger('dev'));
}
//--
//app.use(session());//Si on enleve ce use impossible de garder le req.user en app.locals.user....
// Parser
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(flash());
//--
// Static path
app.use(express.static(path.join(__dirname, 'public')));
//--
// Managment Session Store
var sessionStore = require('./otf_core/lib/otf_session')(app, secret, cookie_name);
//--
// OPOLOG PLUBISH/SUBCRIBE WEBSOCKET FRAMEWORK
require('./otf_core/lib/otf_oplog')(sessionStore);
//--
// Authentification Managment by Passport
require('./otf_core/lib/otf_passport')(app);
app.use(function(req, res, next){
app.locals.query = req.query;
// console.log('???????????????????? req.user : ', req.user);
app.locals.url = req.url;
app.locals.user = req.user;//permet de garder les infos du user connecté
// app.locals.url_public = properties.url_public;
next();
});
//--
// Sequelize configuration like GLOBAL actualy, but not in the future.
dbSeq = require('./otf_core/lib/otf_sequelize');
app.set('models', require('./conf/models'));
//--
// Routes Managment by Otf Framework
require('./otf_core/otf')(app, sessionStore);
//--
//WebSocket Managment
require('./otf_core/lib/otf_websocket')(sessionStore, secret, cookie_name);
//--
//-- TEST PASSAGE CONTEXT APPLICATIF
app.locals.test = 'OTF localsValue';
app.set('test', 'OTF setValue');
//-- Make the instance object app global
// export app
module.exports = app;