Settings.js, express.js: trivial reformatting

Future commits by Tristram Gräbener will modify them.
This commit is contained in:
muxator 2019-04-16 00:17:56 +02:00
parent dc7e49f89d
commit 75a0f339e1
2 changed files with 41 additions and 35 deletions

View file

@ -19,20 +19,20 @@ exports.createServer = function () {
exports.restartServer();
console.log(`You can access your Etherpad instance at http://${settings.ip}:${settings.port}/`);
if(!_.isEmpty(settings.users)){
if (!_.isEmpty(settings.users)) {
console.log(`The plugin admin page is at http://${settings.ip}:${settings.port}/admin/plugins`);
}
else{
} else {
console.warn("Admin username and password not set in settings.json. To access admin please uncomment and edit 'users' in settings.json");
}
var env = process.env.NODE_ENV || 'development';
if(env !== 'production'){
if (env !== 'production') {
console.warn("Etherpad is running in Development mode. This mode is slower for users and less secure than production mode. You should set the NODE_ENV environment variable to production by using: export NODE_ENV=production");
}
}
exports.restartServer = function () {
if (server) {
console.log("Restarting express server");
server.close();
@ -41,7 +41,6 @@ exports.restartServer = function () {
var app = express(); // New syntax for express v3
if (settings.ssl) {
console.log("SSL -- enabled");
console.log(`SSL -- server key file: ${settings.ssl.key}`);
console.log(`SSL -- Certificate Authority's certificate file: ${settings.ssl.cert}`);
@ -50,9 +49,10 @@ exports.restartServer = function () {
key: fs.readFileSync( settings.ssl.key ),
cert: fs.readFileSync( settings.ssl.cert )
};
if (settings.ssl.ca) {
options.ca = [];
for(var i = 0; i < settings.ssl.ca.length; i++) {
for (var i = 0; i < settings.ssl.ca.length; i++) {
var caFileName = settings.ssl.ca[i];
options.ca.push(fs.readFileSync(caFileName));
}
@ -60,16 +60,15 @@ exports.restartServer = function () {
var https = require('https');
server = https.createServer(options, app);
} else {
var http = require('http');
server = http.createServer(app);
}
app.use(function (req, res, next) {
app.use(function(req, res, next) {
// res.header("X-Frame-Options", "deny"); // breaks embedded pads
if(settings.ssl){ // if we use SSL
if (settings.ssl) {
// we use SSL
res.header("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
}
@ -80,7 +79,7 @@ exports.restartServer = function () {
next();
});
if(settings.trustProxy){
if (settings.trustProxy) {
app.enable('trust proxy');
}