Compare commits

..

No commits in common. "1ff5c302511078687a81b6466ab16551f5ab705e" and "4ff7dad6f107d662e6389e5bcb15b2269de3e4ac" have entirely different histories.

254 changed files with 1647 additions and 868 deletions

94
app.js
View file

@ -1,61 +1,61 @@
//NOTE: SERVER CONFIGURATION has 2 options. ENABLE 1 of 2 options
//NOTE: option (1) - https server (443) + redirection 80 to 443
// //NOTE: option (1) - https server (443) + redirection 80 to 443
//prepare credentials & etc
var fs = require('fs');
var https = require('https');
var privateKey = fs.readFileSync('/etc/letsencrypt/live/choir.run/privkey.pem', 'utf8');
var certificate = fs.readFileSync('/etc/letsencrypt/live/choir.run/fullchain.pem', 'utf8');
var credentials = {
key: privateKey,
cert: certificate
};
// //prepare credentials & etc
// var fs = require('fs');
// var https = require('https');
// var privateKey = fs.readFileSync('/etc/letsencrypt/live/choir.run/privkey.pem', 'utf8');
// var certificate = fs.readFileSync('/etc/letsencrypt/live/choir.run/fullchain.pem', 'utf8');
// var credentials = {
// key: privateKey,
// cert: certificate
// };
//https WWW server @ port 443
var express = require('express');
var app = express();
var httpsWebServer = https.createServer(credentials, app).listen(443, function() {
console.log('[express] listening on *:443');
});
//http Redirection server @ port 80
// ==> Don't get why this works.. all others not. ==> https://stackoverflow.com/a/23283173
var http = require('http');
var httpApp = express();
var httpRouter = express.Router();
httpApp.use('*', httpRouter);
httpRouter.get('*', function(req, res) {
var host = req.get('Host');
// replace the port in the host
host = host.replace(/:\d+$/, ":" + app.get('port'));
// determine the redirect destination
var destination = ['https://', host, req.url].join('');
return res.redirect(destination);
});
var httpServer = http.createServer(httpApp);
httpServer.listen(80);
//https socket.io server @ port 443 (same port as WWW service)
var io = require('socket.io')(httpsWebServer, {
'pingInterval': 1000,
'pingTimeout': 3000
});
// //NOTE: option (2) - simple http dev server (8080)
// var http = require('http');
// //https WWW server @ port 443
// var express = require('express');
// var app = express();
// var httpServer = http.createServer(app);
// httpServer.listen(8080);
// var httpsWebServer = https.createServer(credentials, app).listen(443, function() {
// console.log('[express] listening on *:443');
// });
// //http socket.io server @ port 8080 (same port as WWW service)
// var io = require('socket.io')(httpServer, {
// //http Redirection server @ port 80
// // ==> Don't get why this works.. all others not. ==> https://stackoverflow.com/a/23283173
// var http = require('http');
// var httpApp = express();
// var httpRouter = express.Router();
// httpApp.use('*', httpRouter);
// httpRouter.get('*', function(req, res) {
// var host = req.get('Host');
// // replace the port in the host
// host = host.replace(/:\d+$/, ":" + app.get('port'));
// // determine the redirect destination
// var destination = ['https://', host, req.url].join('');
// return res.redirect(destination);
// });
// var httpServer = http.createServer(httpApp);
// httpServer.listen(80);
// //https socket.io server @ port 443 (same port as WWW service)
// var io = require('socket.io')(httpsWebServer, {
// 'pingInterval': 1000,
// 'pingTimeout': 3000
// });
//NOTE: option (2) - simple http dev server (8080)
var http = require('http');
var express = require('express');
var app = express();
var httpServer = http.createServer(app);
httpServer.listen(8080);
//http socket.io server @ port 8080 (same port as WWW service)
var io = require('socket.io')(httpServer, {
'pingInterval': 1000,
'pingTimeout': 3000
});
//express configuration
app.use(express.static('public'));

2226
package-lock.json generated

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more