Wired up link-redirects to Ghost services & web server

refs https://github.com/TryGhost/Team/issues/1887
This commit is contained in:
Fabien "egg" O'Carroll 2022-09-13 18:26:35 -04:00 committed by Fabien 'egg' O'Carroll
parent 160a0f881e
commit ae281eb226
4 changed files with 26 additions and 1 deletions

View File

@ -156,9 +156,14 @@ async function initServicesForFrontend({bootLogger}) {
debug('Begin: Redirects');
const customRedirects = require('./server/services/custom-redirects');
await customRedirects.init(),
await customRedirects.init();
debug('End: Redirects');
debug('Begin: Link Redirects');
const linkRedirects = require('./server/services/link-redirection');
await linkRedirects.init();
debug('End: Link Redirects');
debug('Begin: Themes');
// customThemSettingsService.api must be initialized before any theme activation occurs
const customThemeSettingsService = require('./server/services/custom-theme-settings');

View File

@ -15,6 +15,7 @@ const themeMiddleware = themeEngine.middleware;
const membersService = require('../../server/services/members');
const offersService = require('../../server/services/offers');
const customRedirects = require('../../server/services/custom-redirects');
const linkRedirects = require('../../server/services/link-redirection');
const siteRoutes = require('./routes');
const shared = require('../../server/web/shared');
const errorHandler = require('@tryghost/mw-error-handler');
@ -49,6 +50,8 @@ module.exports = function setupSiteApp(routerConfig) {
siteApp.use(offersService.middleware);
siteApp.use(linkRedirects.service.handleRequest);
// you can extend Ghost with a custom redirects file
// see https://github.com/TryGhost/Ghost/issues/7707
siteApp.use(customRedirects.middleware);

View File

@ -0,0 +1,16 @@
class LinkRedirectsServiceWrapper {
async init() {
if (this.service) {
// Already done
return;
}
// Wire up all the dependencies
const {LinkRedirectsService} = require('@tryghost/link-redirects');
// Expose the service
this.service = new LinkRedirectsService();
}
}
module.exports = new LinkRedirectsServiceWrapper();

View File

@ -81,6 +81,7 @@
"@tryghost/kg-default-cards": "5.18.0",
"@tryghost/kg-mobiledoc-html-renderer": "5.3.7",
"@tryghost/limit-service": "1.2.3",
"@tryghost/link-redirects": "0.0.0",
"@tryghost/logging": "2.3.0",
"@tryghost/magic-link": "0.0.0",
"@tryghost/mailgun-client": "0.0.0",