mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
c7b843471f
refs: https://github.com/TryGhost/Team/issues/510 - added and wired up the new limit service, which is a lazy-loaded service - this handles the case that there are host limits set in config, and wraps all the logic needed for detecting exceeded limits & throwing limit errors - expects limits to be set in config under `host_settings.limits` - supported limits are managed in the limit service, outside of core
25 lines
757 B
JavaScript
25 lines
757 B
JavaScript
const config = require('../../shared/config');
|
|
const db = require('../data/db');
|
|
const LimitService = require('@tryghost/limit-service');
|
|
let limitService = new LimitService();
|
|
|
|
const initFn = () => {
|
|
let helpLink;
|
|
|
|
if (!config.get('host_settings') || !config.get('host_settings:limits')) {
|
|
return;
|
|
}
|
|
|
|
if (config.get('host_settings:billing:enabled') && config.get('host_settings:billing:enabled') === true && config.get('host_settings:billing:url')) {
|
|
helpLink = config.get('host_settings:billing:url');
|
|
} else {
|
|
helpLink = 'https://ghost.org/help/';
|
|
}
|
|
|
|
limitService.loadLimits({limits: config.get('host_settings:limits'), db, helpLink});
|
|
};
|
|
|
|
module.exports = limitService;
|
|
|
|
module.exports.init = initFn;
|