-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
126 lines (109 loc) · 3.46 KB
/
server.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var http = require('http'),
https = require('https'),
fs = require('fs'),
express = require('express'),
favicon = require('static-favicon'),
bodyParser = require('body-parser'),
sessions = require('client-sessions'),
ejs = require('ejs'),
mongoose = require('mongoose');
var httpProxy = require('http-proxy');
var app = express();
var routes = require('./routes');
//Server on
var server = http.createServer(app).listen(3000, function(){
console.log("Express server listening on port " + 3000);
});
var io = require('socket.io').listen(server);
var i18n = require('i18next');
i18n.init({
load: 'current',
saveMissing: true,
cookieName: 'lang',
resGetPath: 'locales/__lng__.json',
detectLngFromPath: 0,
detectLngFromHeaders: false,
supportedLngs: ['en', 'fr'],
fallbackLng: 'en'
});
//Config
app.use('/public', express.static('public'));
app.use(favicon(__dirname + '/public/img/favicon.ico'));
app.use(bodyParser());
app.use(sessions({
cookieName: 'Identity',
secret: 'Jamdude599*=/Hih98&*@32454d0',
duration: 24 * 60 * 60 * 1000
}));
i18n.registerAppHelper(app);
app.use(i18n.handle);
module.exports.app = app;
module.exports.i18n = i18n;
ejs.filters.t = function(key) {
return i18n.t(key);
};
//Get link
app.get('/', routes.index);
//LANG
app.get('/fr', routes.lang_fr);
app.get('/en', routes.lang_en);
//Menu
app.get('/game', routes.game);
app.get('/subscribe', routes.subscribe);
app.get('/pwdchange', routes.pwdchange);
app.get('/login', routes.login);
app.get('/delog', routes.delog);
app.get('/index', routes.index);
app.get('/list', routes.list);
app.get('/ldap', routes.ldap);
app.get('/ticket', routes.ticket);
//Forum edit
app.get('/forum/:path/:path/:path/edit', routes.edit);
app.get('/forum/:path/:path/edit', routes.edit);
app.get('/forum/:path/edit', routes.edit);
app.get('/forum/edit', routes.edit);
//Forum delete
app.get('/forum/:path/:path/:path/delete', routes.delete);
app.get('/forum/:path/:path/delete', routes.delete);
app.get('/forum/:path/delete', routes.delete);
app.get('/forum/delete', routes.delete);
//Forum new topic
app.get('/forum/:path/:path/new_topic', routes.new_topic);
app.get('/forum/:path/new_topic', routes.new_topic);
app.get('/forum/new_topic', routes.new_topic);
//else
app.get('/forum/:path/:path/:path', routes.forum_final);
app.get('/forum/:path/:path', routes.forum);
app.get('/forum/:path', routes.forum);
app.get('/forum', routes.forum_index);
app.get('/admin', routes.admin);
//IO socket
io.set('authorization', routes.auth_socket);
io.sockets.on('connection', routes.s_connect);
//Post link
app.post('/subscribe', routes.create);
app.post('/login', routes.logging);
app.post('/pwdchange', routes.change_pwd);
app.post('/ticket', routes.ticket_post);
//Forum edit post
app.post('/forum/:path/:path/:path/edit', routes.edit_post);
app.post('/forum/:path/:path/edit', routes.edit_post);
app.post('/forum/:path/edit', routes.edit_post);
app.post('/forum/edit', routes.edit_post);
app.post('/forum/:path/:path/new_topic', routes.post_new_topic);
app.post('/forum/:path/:path/:path', routes.display_reply);
app.post('/forum/:path/new_topic', routes.post_new_topic);
app.post('/forum/new_topic', routes.post_new_topic);
app.post('/admin', routes.admin_change);
//Error
app.use(routes.default);
// httpProxy.createServer({
// target: {
// host: 'localhost',
// port: 9009
// },
// ssl: {
// key: fs.readFileSync(__dirname + '/data/ssl/key.pem', 'utf8'),
// cert: fs.readFileSync(__dirname + '/data/ssl/csr.pem', 'utf8')
// }
// }).listen(8009);