mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 12:21:36 +03: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
@ -8,11 +8,20 @@ class LimitService {
|
|||||||
this.limits = {};
|
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}) {
|
loadLimits({limits, helpLink, db}) {
|
||||||
Object.keys(limits).forEach((name) => {
|
Object.keys(limits).forEach((name) => {
|
||||||
name = _.camelCase(name);
|
name = _.camelCase(name);
|
||||||
|
|
||||||
if (config[name]) {
|
if (config[name]) {
|
||||||
|
/** @type LimitConfig */
|
||||||
let limitConfig = _.merge({}, limits[name], config[name]);
|
let limitConfig = _.merge({}, limits[name], config[name]);
|
||||||
|
|
||||||
if (_.has(limitConfig, 'max')) {
|
if (_.has(limitConfig, 'max')) {
|
||||||
@ -76,3 +85,10 @@ class LimitService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = 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…
Reference in New Issue
Block a user