-
Notifications
You must be signed in to change notification settings - Fork 19
/
server.js
executable file
·45 lines (31 loc) · 1.26 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
'use strict';
// general routing framework
var express = require('express')
//var basicAuth = require('basic-auth-connect');
var app = express()
// password protection
//app.use(basicAuth('story2020', 'ilovestory'));
// declare the list of sub apps
var app_names = [];
var hyblab2022_names = ['abstention-1', 'abstention-2', 'twitter-1', 'twitter-2', 'communes-1', 'communes-2', 'q-a-1', 'q-a-2', 'sondages', 'pouvoirs'];
app_names.push.apply(app_names, hyblab2022_names);
var sub_apps = [];
// create sub apps
// and register sub-apps
app_names.forEach( function( element, index, array) {
console.log('Registering: ' + element);
sub_apps[element] = require('./' + element + '/server');
app.use('/' + element, sub_apps[element]);
});
// redirect catch all url to hyblab website (disabled for dev)
//app.use(/\/$/,function(req, res, next){
// res.redirect('http://www.hyblab.fr/');
//});
// launch main server app
//warning: do not change the port, it will be automatically taken from env en dev and prod servers ...
var port = 'PORT' in process.env ? process.env.PORT : 8080;
var server = app.listen(port, function () {
var host = server.address().address
var port = server.address().port
console.log('Hyblab routing app listening at http://%s:%s', host, port)
})