Ghost/core/server/web/parent/app.js
Hannah Wolfe 7e61f73b8c
Moved vhost mounts into boot file
- 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!
2021-07-07 21:29:14 +01:00

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');