Ghost/core/server/services/limits.js
Hannah Wolfe c7b843471f Added limit service
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
2021-03-03 13:43:05 +00:00

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;