fix: Parse Server option maxLogFiles doesn't recognize day duration literals such as 1d to mean 1 day (#9215)

This commit is contained in:
Diamond Lewis
2024-07-18 08:41:59 -05:00
committed by GitHub
parent 901cff5edd
commit 0319cee2db
4 changed files with 27 additions and 1 deletions

View File

@@ -378,7 +378,7 @@ module.exports.ParseServerOptions = {
env: 'PARSE_SERVER_MAX_LOG_FILES',
help:
"Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null)",
action: parsers.objectParser,
action: parsers.numberOrStringParser('maxLogFiles'),
},
maxUploadSize: {
env: 'PARSE_SERVER_MAX_UPLOAD_SIZE',

View File

@@ -23,6 +23,15 @@ function numberOrBoolParser(key) {
};
}
function numberOrStringParser(key) {
return function (opt) {
if (typeof opt === 'string') {
return opt;
}
return numberParser(key)(opt);
};
}
function objectParser(opt) {
if (typeof opt == 'object') {
return opt;
@@ -69,6 +78,7 @@ function nullParser(opt) {
module.exports = {
numberParser,
numberOrBoolParser,
numberOrStringParser,
nullParser,
booleanParser,
moduleOrObjectParser,