0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Refactored CustomRedirectsAPI constructor

refs https://github.com/TryGhost/Toolbox/issues/139

- The pattern we use accross the codebase is a single "options" object passed into a constructor instead of passing multiple parametes. Fixed the broken pattern in CustomRedirectsAPI constructor
This commit is contained in:
Naz 2021-11-25 12:43:15 +04:00 committed by naz
parent 3a9b70412a
commit fd0a0ddf47
2 changed files with 8 additions and 7 deletions

View file

@ -138,12 +138,12 @@ class CustomRedirectsAPI {
/** /**
* @param {object} config * @param {object} config
* @param {string} config.basePath * @param {string} config.basePath
* * @param {IRedirectManager} config.redirectManager
* @param {IRedirectManager} redirectManager
*/ */
constructor(config, redirectManager) { constructor({basePath, redirectManager}) {
/** @private */ /** @private */
this.config = config; this.basePath = basePath;
/** @private */ /** @private */
this.redirectManager = redirectManager; this.redirectManager = redirectManager;
} }
@ -187,7 +187,7 @@ class CustomRedirectsAPI {
* @returns {string} * @returns {string}
*/ */
createRedirectsFilePath(ext) { createRedirectsFilePath(ext) {
return path.join(this.config.basePath, `redirects${ext}`); return path.join(this.basePath, `redirects${ext}`);
} }
/** /**

View file

@ -16,8 +16,9 @@ let customRedirectsAPI;
module.exports = { module.exports = {
init() { init() {
customRedirectsAPI = new CustomRedirectsAPI({ customRedirectsAPI = new CustomRedirectsAPI({
basePath: config.getContentPath('data') basePath: config.getContentPath('data'),
}, redirectManager); redirectManager
});
return customRedirectsAPI.init(); return customRedirectsAPI.init();
}, },