0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Moved web/parent-app to web/parent/app

- Have a consistent structure so we can co-locate an app with its own middleware
- This is another small step in sorting out the giant mess that was web/shared/middleware
This commit is contained in:
Hannah Wolfe 2020-04-21 18:08:29 +01:00
parent 61633d48ee
commit becc239de1
4 changed files with 15 additions and 19 deletions

View file

@ -103,7 +103,7 @@ const minimalRequiredSetupToStartGhost = (dbState) => {
.then(() => { .then(() => {
debug('Themes done'); debug('Themes done');
parentApp = require('./web/parent-app')(); parentApp = require('./web/parent/app')();
debug('Express Apps done'); debug('Express Apps done');
return new GhostServer(parentApp); return new GhostServer(parentApp);

View file

@ -1,13 +1,13 @@
const debug = require('ghost-ignition').debug('web:parent'); const debug = require('ghost-ignition').debug('web:parent');
const express = require('express'); const express = require('express');
const vhost = require('@tryghost/vhost-middleware'); const vhost = require('@tryghost/vhost-middleware');
const config = require('../config'); const config = require('../../config');
const compress = require('compression'); const compress = require('compression');
const netjet = require('netjet'); const netjet = require('netjet');
const shared = require('./shared'); const shared = require('../shared');
const escapeRegExp = require('lodash.escaperegexp'); const escapeRegExp = require('lodash.escaperegexp');
const {URL} = require('url'); const {URL} = require('url');
const sentry = require('../sentry'); const sentry = require('../../sentry');
module.exports = function setupParentApp(options = {}) { module.exports = function setupParentApp(options = {}) {
debug('ParentApp setup start'); debug('ParentApp setup start');
@ -53,9 +53,9 @@ module.exports = function setupParentApp(options = {}) {
const adminApp = express(); const adminApp = express();
adminApp.use(sentry.requestHandler); adminApp.use(sentry.requestHandler);
adminApp.enable('trust proxy'); // required to respect x-forwarded-proto in admin requests adminApp.enable('trust proxy'); // required to respect x-forwarded-proto in admin requests
adminApp.use('/ghost/api', require('./api')()); adminApp.use('/ghost/api', require('../api')());
adminApp.use('/ghost/.well-known', require('./well-known')()); adminApp.use('/ghost/.well-known', require('../well-known')());
adminApp.use('/ghost', require('../services/auth/session').createSessionFromToken, require('./admin')()); adminApp.use('/ghost', require('../../services/auth/session').createSessionFromToken, require('../admin')());
// ADMIN + API // ADMIN + API
// with a separate admin url only serve on that host, otherwise serve on all hosts // with a separate admin url only serve on that host, otherwise serve on all hosts
@ -67,7 +67,7 @@ module.exports = function setupParentApp(options = {}) {
const frontendVhostArg = (hasSeparateAdmin && adminHost) ? const frontendVhostArg = (hasSeparateAdmin && adminHost) ?
new RegExp(`^(?!${escapeRegExp(adminHost)}).*`) : /.*/; new RegExp(`^(?!${escapeRegExp(adminHost)}).*`) : /.*/;
parentApp.use(vhost(frontendVhostArg, require('./site')(options))); parentApp.use(vhost(frontendVhostArg, require('../site')(options)));
debug('ParentApp setup end'); debug('ParentApp setup end');

View file

@ -9,7 +9,7 @@ const should = require('should'),
appService = require('../../../core/frontend/services/apps'), appService = require('../../../core/frontend/services/apps'),
frontendSettingsService = require('../../../core/frontend/services/settings'), frontendSettingsService = require('../../../core/frontend/services/settings'),
themeService = require('../../../core/frontend/services/themes'), themeService = require('../../../core/frontend/services/themes'),
siteApp = require('../../../core/server/web/parent-app'); siteApp = require('../../../core/server/web/parent/app');
describe('Integration - Web - Site', function () { describe('Integration - Web - Site', function () {
let app; let app;

View file

@ -1,7 +1,7 @@
const should = require('should'); const should = require('should');
const sinon = require('sinon'); const sinon = require('sinon');
const proxyquire = require('proxyquire').noCallThru(); const proxyquire = require('proxyquire').noCallThru();
const configUtils = require('../../utils/configUtils'); const configUtils = require('../../../utils/configUtils');
describe('parent app', function () { describe('parent app', function () {
let expressStub; let expressStub;
@ -30,17 +30,13 @@ describe('parent app', function () {
gatewaySpy = sinon.spy(); gatewaySpy = sinon.spy();
authPagesSpy = sinon.spy(); authPagesSpy = sinon.spy();
parentApp = proxyquire('../../../core/server/web/parent-app', { parentApp = proxyquire('../../../../core/server/web/parent/app', {
express: expressStub, express: expressStub,
'@tryghost/vhost-middleware': vhostSpy, '@tryghost/vhost-middleware': vhostSpy,
'./api': apiSpy, '../api': apiSpy,
'./admin': adminSpy, '../admin': adminSpy,
'./well-known': wellKnownSpy, '../well-known': wellKnownSpy,
'./site': siteSpy, '../site': siteSpy
'../services/members': {
gateway: gatewaySpy,
authPages: authPagesSpy
}
}); });
configUtils.set('url', 'http://ghost.blog'); configUtils.set('url', 'http://ghost.blog');