mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
7e61f73b8c
- 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!
32 lines
973 B
JavaScript
32 lines
973 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 emmiter 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;
|
|
};
|
|
|
|
// const vhostUtils = require('./vhost-utils');
|