diff --git a/ghost/limit-service/lib/limit-service.js b/ghost/limit-service/lib/limit-service.js index 6ab6b85e67..7b9d2d4842 100644 --- a/ghost/limit-service/lib/limit-service.js +++ b/ghost/limit-service/lib/limit-service.js @@ -8,11 +8,20 @@ class LimitService { this.limits = {}; } + /** + * Initializes the limits based on configuration + * + * @param {Object} options + * @param {Object} options.limits - hash containing limit configurations keyed by limit name and containing + * @param {String} options.helpLink - URL pointing to help resources for when limit is reached + * @param {Object} options.db - knex db connection instance or other data source for the limit checks + */ loadLimits({limits, helpLink, db}) { Object.keys(limits).forEach((name) => { name = _.camelCase(name); if (config[name]) { + /** @type LimitConfig */ let limitConfig = _.merge({}, limits[name], config[name]); if (_.has(limitConfig, 'max')) { @@ -76,3 +85,10 @@ class LimitService { } module.exports = LimitService; + +/** + * @typedef {Object} LimitConfig + * @prop {Number} [max] - max limit + * @prop {Boolean} [disabled] - flag disabling/enabling limit + * @prop {String} error - custom error to be displayed when the limit is reached + */