mirror of https://github.com/xwiki-labs/cryptpad
standardize loading of server configuration
This commit is contained in:
parent
670040ae68
commit
d5a9eacef0
|
@ -0,0 +1,12 @@
|
||||||
|
var config;
|
||||||
|
try {
|
||||||
|
config = require("../config/config");
|
||||||
|
if (config.adminEmail === 'i.did.not.read.my.config@cryptpad.fr') {
|
||||||
|
console.log("You can configure the administrator email (adminEmail) in your config/config.js file");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log("You can customize the configuration by copying config/config.example.js to config/config.js");
|
||||||
|
config = require("../config/config.example");
|
||||||
|
}
|
||||||
|
module.exports = config;
|
||||||
|
|
|
@ -4,7 +4,7 @@ const nThen = require('nthen');
|
||||||
const Pinned = require('./pinned');
|
const Pinned = require('./pinned');
|
||||||
const Nacl = require('tweetnacl');
|
const Nacl = require('tweetnacl');
|
||||||
const Path = require('path');
|
const Path = require('path');
|
||||||
const Config = require('./load-config');
|
const Config = require('../lib/load-config');
|
||||||
|
|
||||||
const hashesFromPinFile = (pinFile, fileName) => {
|
const hashesFromPinFile = (pinFile, fileName) => {
|
||||||
var pins = {};
|
var pins = {};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* globals Buffer */
|
/* globals Buffer */
|
||||||
var Https = require('https');
|
var Https = require('https');
|
||||||
var Config = require("../config/config.js");
|
var Config = require("../lib/load-config");
|
||||||
var Package = require("../package.json");
|
var Package = require("../package.json");
|
||||||
|
|
||||||
var body = JSON.stringify({
|
var body = JSON.stringify({
|
||||||
|
|
|
@ -3,12 +3,7 @@ const Fs = require("fs");
|
||||||
const nThen = require("nthen");
|
const nThen = require("nthen");
|
||||||
const Saferphore = require("saferphore");
|
const Saferphore = require("saferphore");
|
||||||
const PinnedData = require('./pinneddata');
|
const PinnedData = require('./pinneddata');
|
||||||
let config;
|
const config = require("../lib/load-config");
|
||||||
try {
|
|
||||||
config = require('./config/config');
|
|
||||||
} catch (e) {
|
|
||||||
config = require('./config/config.example');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!config.inactiveTime || typeof(config.inactiveTime) !== "number") { return; }
|
if (!config.inactiveTime || typeof(config.inactiveTime) !== "number") { return; }
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ var Path = require("path");
|
||||||
|
|
||||||
var nThen = require("nthen");
|
var nThen = require("nthen");
|
||||||
|
|
||||||
var config = require("./load-config");
|
var config = require("../lib/load-config");
|
||||||
|
|
||||||
var FileStorage = require('../' + config.storage || './storage/file');
|
var FileStorage = require('../' + config.storage || './storage/file');
|
||||||
var root = Path.resolve('../' + config.taskPath || './tasks');
|
var root = Path.resolve('../' + config.taskPath || './tasks');
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
var config;
|
|
||||||
try {
|
|
||||||
config = require("../config/config");
|
|
||||||
} catch (e) {
|
|
||||||
config = require("../config/config.example");
|
|
||||||
}
|
|
||||||
module.exports = config;
|
|
|
@ -106,6 +106,6 @@ if (!module.parent) {
|
||||||
console.log(x + ' ' + JSON.stringify(data[x]));
|
console.log(x + ' ' + JSON.stringify(data[x]));
|
||||||
});
|
});
|
||||||
}, {
|
}, {
|
||||||
pinPath: require("../config/config").pinPath
|
pinPath: require("../lib/load-config").pinPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
12
server.js
12
server.js
|
@ -11,17 +11,7 @@ var Package = require('./package.json');
|
||||||
var Path = require("path");
|
var Path = require("path");
|
||||||
var nThen = require("nthen");
|
var nThen = require("nthen");
|
||||||
|
|
||||||
var config;
|
var config = require("./lib/load-config");
|
||||||
try {
|
|
||||||
config = require('./config/config');
|
|
||||||
} catch (e) {
|
|
||||||
console.log("You can customize the configuration by copying config/config.example.js to config/config.js");
|
|
||||||
config = require('./config/config.example');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.adminEmail === 'i.did.not.read.my.config@cryptpad.fr') {
|
|
||||||
console.log("You can configure the administrator email (adminEmail) in your config/config.js file");
|
|
||||||
}
|
|
||||||
|
|
||||||
var websocketPort = config.websocketPort || config.httpPort;
|
var websocketPort = config.websocketPort || config.httpPort;
|
||||||
var useSecureWebsockets = config.useSecureWebsockets || false;
|
var useSecureWebsockets = config.useSecureWebsockets || false;
|
||||||
|
|
Loading…
Reference in New Issue