From c16f13b10698367e1c049a3a81789dd96f775113 Mon Sep 17 00:00:00 2001 From: Naz Date: Mon, 5 Apr 2021 16:02:35 +1200 Subject: [PATCH] Added JSDoc to loadLimits method refs https://github.com/TryGhost/Team/issues/597 - Before adding more parameters documented existing ones - Created LimitConfig type definition to have easier look into the structure of limit conifiguration --- ghost/limit-service/lib/limit-service.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 + */