From de6b9e2228c7537f77b3c80688d1468fa1c97d3e Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 28 Feb 2020 10:50:30 -0500 Subject: [PATCH] apply some defaults when loading the config --- lib/load-config.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/load-config.js b/lib/load-config.js index 1c502226a..0b861b826 100644 --- a/lib/load-config.js +++ b/lib/load-config.js @@ -18,5 +18,23 @@ try { } config = require("../config/config.example"); } + +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; +} + module.exports = config;