express: Use `const` and `let` instead of `var`
Also: * Sort imports. * Use single quotes. * Abbreviate module names.pull/4383/head
parent
b68969fbac
commit
3f8365a995
|
@ -1,13 +1,13 @@
|
||||||
var hooks = require("ep_etherpad-lite/static/js/pluginfw/hooks");
|
const _ = require('underscore');
|
||||||
var express = require('express');
|
const express = require('express');
|
||||||
var settings = require('../utils/Settings');
|
const fs = require('fs');
|
||||||
var fs = require('fs');
|
const hooks = require('../../static/js/pluginfw/hooks');
|
||||||
var path = require('path');
|
const npm = require('npm/lib/npm');
|
||||||
var npm = require("npm/lib/npm.js");
|
const path = require('path');
|
||||||
var _ = require("underscore");
|
const settings = require('../utils/Settings');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
|
||||||
var serverName;
|
let serverName;
|
||||||
|
|
||||||
exports.server = null;
|
exports.server = null;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ exports.createServer = async () => {
|
||||||
console.warn("Admin username and password not set in settings.json. To access admin please uncomment and edit 'users' in settings.json");
|
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';
|
const 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");
|
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");
|
||||||
|
@ -46,30 +46,30 @@ exports.restartServer = async () => {
|
||||||
await util.promisify(exports.server.close).bind(exports.server)();
|
await util.promisify(exports.server.close).bind(exports.server)();
|
||||||
}
|
}
|
||||||
|
|
||||||
var app = express(); // New syntax for express v3
|
const app = express(); // New syntax for express v3
|
||||||
|
|
||||||
if (settings.ssl) {
|
if (settings.ssl) {
|
||||||
console.log("SSL -- enabled");
|
console.log("SSL -- enabled");
|
||||||
console.log(`SSL -- server key file: ${settings.ssl.key}`);
|
console.log(`SSL -- server key file: ${settings.ssl.key}`);
|
||||||
console.log(`SSL -- Certificate Authority's certificate file: ${settings.ssl.cert}`);
|
console.log(`SSL -- Certificate Authority's certificate file: ${settings.ssl.cert}`);
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
key: fs.readFileSync( settings.ssl.key ),
|
key: fs.readFileSync( settings.ssl.key ),
|
||||||
cert: fs.readFileSync( settings.ssl.cert )
|
cert: fs.readFileSync( settings.ssl.cert )
|
||||||
};
|
};
|
||||||
|
|
||||||
if (settings.ssl.ca) {
|
if (settings.ssl.ca) {
|
||||||
options.ca = [];
|
options.ca = [];
|
||||||
for (var i = 0; i < settings.ssl.ca.length; i++) {
|
for (let i = 0; i < settings.ssl.ca.length; i++) {
|
||||||
var caFileName = settings.ssl.ca[i];
|
const caFileName = settings.ssl.ca[i];
|
||||||
options.ca.push(fs.readFileSync(caFileName));
|
options.ca.push(fs.readFileSync(caFileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var https = require('https');
|
const https = require('https');
|
||||||
exports.server = https.createServer(options, app);
|
exports.server = https.createServer(options, app);
|
||||||
} else {
|
} else {
|
||||||
var http = require('http');
|
const http = require('http');
|
||||||
exports.server = http.createServer(app);
|
exports.server = http.createServer(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue