mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
b19424acb3
refs https://github.com/TryGhost/Toolbox/issues/152 - This stops the mounting of the admin and frontend from being buried deep in express initialisation - Instead it's explicit, which makes two things almost possible: 1. we can potentially boot the frontend or backend independently 2. we can pass services and settings loaded during boot into the frontend - This needs more work, but we can start to group all the frontend code together - Meanwhile we also need to rip apart the routing and url services to decouple the frontend from the backend fully - BABY STEPS! Co-authored-by: Hannah Wolfe <erisds@gmail.com>
30 lines
924 B
JavaScript
30 lines
924 B
JavaScript
const debug = require('@tryghost/debug')('web:parent');
|
|
const config = require('../../../shared/config');
|
|
const express = require('../../../shared/express');
|
|
const compress = require('compression');
|
|
const mw = require('./middleware');
|
|
|
|
module.exports = function setupParentApp() {
|
|
debug('ParentApp setup start');
|
|
const parentApp = express('parent');
|
|
|
|
parentApp.use(mw.requestId);
|
|
parentApp.use(mw.logRequest);
|
|
|
|
// Register event emitter on req/res to trigger cache invalidation webhook event
|
|
parentApp.use(mw.emitEvents);
|
|
|
|
// enabled gzip compression by default
|
|
if (config.get('compress') !== false) {
|
|
parentApp.use(compress());
|
|
}
|
|
|
|
// This sets global res.locals which are needed everywhere
|
|
// @TODO: figure out if this is really needed everywhere? Is it not frontend only...
|
|
parentApp.use(mw.ghostLocals);
|
|
|
|
debug('ParentApp setup end');
|
|
|
|
return parentApp;
|
|
};
|