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
This commit is contained in:
Naz 2021-04-05 16:02:35 +12:00
parent 01a3e89ef5
commit c16f13b106

View File

@ -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
*/