2023-10-20 22:35:26 +08:00
|
|
|
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2019-05-15 03:43:19 +08:00
|
|
|
"use strict";
|
2024-03-04 21:58:22 +08:00
|
|
|
|
2019-04-17 19:48:39 +08:00
|
|
|
var config;
|
2020-02-28 02:09:12 +08:00
|
|
|
var configPath = process.env.CRYPTPAD_CONFIG || "../config/config.js";
|
2019-04-17 19:48:39 +08:00
|
|
|
try {
|
2019-05-15 03:43:19 +08:00
|
|
|
config = require(configPath);
|
2019-04-17 19:48:39 +08:00
|
|
|
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) {
|
2020-01-05 06:58:01 +08:00
|
|
|
if (e instanceof SyntaxError) {
|
|
|
|
console.error("config/config.js is faulty. See stacktrace below for more information. Terminating. \n");
|
|
|
|
console.error(e.name + ": " + e.message);
|
|
|
|
console.error(e.stack.split("\n\n")[0]);
|
|
|
|
process.exit(1);
|
|
|
|
} else {
|
|
|
|
console.log("Config not found, loading the example config. You can customize the configuration by copying config/config.example.js to " + configPath);
|
|
|
|
}
|
2019-04-17 19:48:39 +08:00
|
|
|
config = require("../config/config.example");
|
|
|
|
}
|
2020-02-28 23:50:30 +08:00
|
|
|
|
|
|
|
var isPositiveNumber = function (n) {
|
|
|
|
return (!isNaN(n) && n >= 0);
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!isPositiveNumber(config.inactiveTime)) {
|
|
|
|
config.inactiveTime = 90;
|
|
|
|
}
|
|
|
|
if (!isPositiveNumber(config.archiveRetentionTime)) {
|
|
|
|
config.archiveRetentionTime = 90;
|
|
|
|
}
|
|
|
|
if (!isPositiveNumber(config.maxUploadSize)) {
|
|
|
|
config.maxUploadSize = 20 * 1024 * 1024;
|
|
|
|
}
|
|
|
|
if (!isPositiveNumber(config.defaultStorageLimit)) {
|
|
|
|
config.defaultStorageLimit = 50 * 1024 * 1024;
|
|
|
|
}
|
|
|
|
|
2020-03-04 05:47:44 +08:00
|
|
|
// premiumUploadSize is worthless if it isn't a valid positive number
|
|
|
|
// or if it's less than the default upload size
|
2020-03-24 04:13:48 +08:00
|
|
|
if (!isPositiveNumber(config.premiumUploadSize) || config.premiumUploadSize < config.maxUploadSize) {
|
2020-03-04 05:47:44 +08:00
|
|
|
delete config.premiumUploadSize;
|
|
|
|
}
|
|
|
|
|
2023-06-23 23:46:14 +08:00
|
|
|
config.sso = {};
|
|
|
|
try {
|
|
|
|
config.sso = require("../config/sso");
|
|
|
|
} catch (e) {
|
2023-12-18 22:53:43 +08:00
|
|
|
//console.log("SSO config not found");
|
2023-06-23 23:46:14 +08:00
|
|
|
}
|
|
|
|
|
2024-03-04 21:58:22 +08:00
|
|
|
module.exports = config;
|