0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Moved ghost-locals mw into parent app

- Moved ghost-locals from shared to parent as it is not shared
- This file is only used in one place, this updates the code structure to reflect this
- This is one of many similar changes needed to make it easier to refactor to the existing setup
- This allows shared middleware to be unhooked from the parent app
This commit is contained in:
Hannah Wolfe 2020-04-21 18:46:52 +01:00
parent 295eac6ea1
commit 213f0a4785
6 changed files with 6 additions and 9 deletions

View file

@ -24,7 +24,7 @@ function setResponseContext(req, res, data) {
res.locals.context = [];
// If we don't have a relativeUrl, we can't detect the context, so return
// See shared/middlewares/ghost-locals
// See web/parent/middleware/ghost-locals
if (!res.locals.relativeUrl) {
return;
}

View file

@ -4,7 +4,6 @@ const vhost = require('@tryghost/vhost-middleware');
const config = require('../../config');
const compress = require('compression');
const netjet = require('netjet');
const shared = require('../shared');
const mw = require('./middleware');
const escapeRegExp = require('lodash.escaperegexp');
const {URL} = require('url');
@ -42,7 +41,8 @@ module.exports = function setupParentApp(options = {}) {
}
// This sets global res.locals which are needed everywhere
parentApp.use(shared.middlewares.ghostLocals);
// @TODO: figure out if this is really needed everywhere? Is it not frontend only...
parentApp.use(mw.ghostLocals);
// Mount the express apps on the parentApp

View file

@ -1,5 +1,6 @@
module.exports = {
emitEvents: require('./emit-events'),
ghostLocals: require('./ghost-locals'),
logRequest: require('./log-request'),
requestId: require('./request-id')
};

View file

@ -31,10 +31,6 @@ module.exports = {
return require('./error-handler');
},
get ghostLocals() {
return require('./ghost-locals');
},
get labs() {
return require('./labs');
},

View file

@ -1,7 +1,7 @@
const should = require('should');
const sinon = require('sinon');
const ghostLocals = require('../../../../core/server/web/shared/middlewares/ghost-locals');
const themeService = require('../../../../core/frontend/services/themes');
const ghostLocals = require('../../../../../core/server/web/parent/middleware/ghost-locals');
const themeService = require('../../../../../core/frontend/services/themes');
describe('Theme Handler', function () {
let req, res, next;