You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

  1. /* jslint node: true */
  2. "use strict";
  3. var config;
  4. var configPath = process.env.CRYPTPAD_CONFIG || "../config/config.js";
  5. try {
  6. config = require(configPath);
  7. if (config.adminEmail === 'i.did.not.read.my.config@cryptpad.fr') {
  8. console.log("You can configure the administrator email (adminEmail) in your config/config.js file");
  9. }
  10. } catch (e) {
  11. if (e instanceof SyntaxError) {
  12. console.error("config/config.js is faulty. See stacktrace below for more information. Terminating. \n");
  13. console.error(e.name + ": " + e.message);
  14. console.error(e.stack.split("\n\n")[0]);
  15. process.exit(1);
  16. } else {
  17. console.log("Config not found, loading the example config. You can customize the configuration by copying config/config.example.js to " + configPath);
  18. }
  19. config = require("../config/config.example");
  20. }
  21. var isPositiveNumber = function (n) {
  22. return (!isNaN(n) && n >= 0);
  23. };
  24. if (!isPositiveNumber(config.inactiveTime)) {
  25. config.inactiveTime = 90;
  26. }
  27. if (!isPositiveNumber(config.archiveRetentionTime)) {
  28. config.archiveRetentionTime = 90;
  29. }
  30. if (!isPositiveNumber(config.maxUploadSize)) {
  31. config.maxUploadSize = 20 * 1024 * 1024;
  32. }
  33. if (!isPositiveNumber(config.defaultStorageLimit)) {
  34. config.defaultStorageLimit = 50 * 1024 * 1024;
  35. }
  36. // premiumUploadSize is worthless if it isn't a valid positive number
  37. // or if it's less than the default upload size
  38. if (!isPositiveNumber(config.premiumUploadSize) || config.premiumUploadSize < config.maxUploadSize) {
  39. delete config.premiumUploadSize;
  40. }
  41. module.exports = config;