mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
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
This commit is contained in:
parent
5de7f2d3fe
commit
c7b843471f
4 changed files with 35 additions and 1 deletions
|
@ -156,6 +156,7 @@ async function initServices({config}) {
|
||||||
const {mega} = require('./server/services/mega');
|
const {mega} = require('./server/services/mega');
|
||||||
const webhooks = require('./server/services/webhooks');
|
const webhooks = require('./server/services/webhooks');
|
||||||
const appService = require('./frontend/services/apps');
|
const appService = require('./frontend/services/apps');
|
||||||
|
const limits = require('./server/services/limits');
|
||||||
const scheduling = require('./server/adapters/scheduling');
|
const scheduling = require('./server/adapters/scheduling');
|
||||||
|
|
||||||
const urlUtils = require('./shared/url-utils');
|
const urlUtils = require('./shared/url-utils');
|
||||||
|
@ -167,6 +168,7 @@ async function initServices({config}) {
|
||||||
mega.listen(),
|
mega.listen(),
|
||||||
webhooks.listen(),
|
webhooks.listen(),
|
||||||
appService.init(),
|
appService.init(),
|
||||||
|
limits.init(),
|
||||||
scheduling.init({
|
scheduling.init({
|
||||||
// NOTE: When changing API version need to consider how to migrate custom scheduling adapters
|
// NOTE: When changing API version need to consider how to migrate custom scheduling adapters
|
||||||
// that rely on URL to lookup persisted scheduled records (jobs, etc.). Ref: https://github.com/TryGhost/Ghost/pull/10726#issuecomment-489557162
|
// that rely on URL to lookup persisted scheduled records (jobs, etc.). Ref: https://github.com/TryGhost/Ghost/pull/10726#issuecomment-489557162
|
||||||
|
|
24
core/server/services/limits.js
Normal file
24
core/server/services/limits.js
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
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;
|
|
@ -56,6 +56,7 @@
|
||||||
"@tryghost/kg-default-cards": "4.0.0-rc.6",
|
"@tryghost/kg-default-cards": "4.0.0-rc.6",
|
||||||
"@tryghost/kg-markdown-html-renderer": "4.0.0-rc.2",
|
"@tryghost/kg-markdown-html-renderer": "4.0.0-rc.2",
|
||||||
"@tryghost/kg-mobiledoc-html-renderer": "4.0.0-rc.1",
|
"@tryghost/kg-mobiledoc-html-renderer": "4.0.0-rc.1",
|
||||||
|
"@tryghost/limit-service": "^0.1.0",
|
||||||
"@tryghost/magic-link": "0.6.7",
|
"@tryghost/magic-link": "0.6.7",
|
||||||
"@tryghost/members-api": "1.0.0-rc.4",
|
"@tryghost/members-api": "1.0.0-rc.4",
|
||||||
"@tryghost/members-csv": "0.4.5",
|
"@tryghost/members-csv": "0.4.5",
|
||||||
|
|
|
@ -495,6 +495,13 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
"@tryghost/kg-clean-basic-html" "^1.0.11"
|
"@tryghost/kg-clean-basic-html" "^1.0.11"
|
||||||
|
|
||||||
|
"@tryghost/limit-service@^0.1.0":
|
||||||
|
version "0.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/@tryghost/limit-service/-/limit-service-0.1.0.tgz#df0b7c4a04858cf655640e1750ad6923da132de2"
|
||||||
|
integrity sha512-9BRAqjSNlqZAedSbry2lULvaCaY4ahAbv+7daRfCLu1ieZPBfQ1wc0pqfgdvGnK2pQRb6X/1WNRHkuaCQigPtg==
|
||||||
|
dependencies:
|
||||||
|
lodash "^4.17.21"
|
||||||
|
|
||||||
"@tryghost/magic-link@0.6.7", "@tryghost/magic-link@^0.6.7":
|
"@tryghost/magic-link@0.6.7", "@tryghost/magic-link@^0.6.7":
|
||||||
version "0.6.7"
|
version "0.6.7"
|
||||||
resolved "https://registry.yarnpkg.com/@tryghost/magic-link/-/magic-link-0.6.7.tgz#9bdf76fa014f08a09cc38c308d659900626902c9"
|
resolved "https://registry.yarnpkg.com/@tryghost/magic-link/-/magic-link-0.6.7.tgz#9bdf76fa014f08a09cc38c308d659900626902c9"
|
||||||
|
@ -5991,7 +5998,7 @@ lodash@4.17.20, lodash@^4.17.20, lodash@~4.17.20:
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||||
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
|
||||||
|
|
||||||
lodash@4.17.21:
|
lodash@4.17.21, lodash@^4.17.21:
|
||||||
version "4.17.21"
|
version "4.17.21"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||||
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
|
||||||
|
|
Loading…
Add table
Reference in a new issue