mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
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:
parent
01a3e89ef5
commit
c16f13b106
1 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue