mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
fdefa4964f
- Modules in /shared are supposed to be standalone modules that can be required by the server or frontend - As the server shouldn't require the frontend, and vice versa, shared modules should require neither - Otherwise it just becomes a crutch for allowing cross-depenencies, and will create circular dependencies The Bridge - The bridge file is not meant to be a crutch sat allowing cross-dependencies, but rather a new component that manages the flow of data - That data flows from the server/boot process TO the frontend, and should not flow in the other direction - The management of that flow of data is necessarily hacky at the moment, but over time the architecture here should get clearer and better - Still, for the time being it will need to handle requiring across components until that architecture matures - Therefore, it should live in core root, not in core/shared
20 lines
739 B
JavaScript
20 lines
739 B
JavaScript
const ghostVersion = require('../../../lib/ghost-version');
|
|
const bridge = require('../../../../bridge');
|
|
|
|
// ### GhostLocals Middleware
|
|
// Expose the standard locals that every request will need to have available
|
|
module.exports = function ghostLocals(req, res, next) {
|
|
// Make sure we have a locals value.
|
|
res.locals = res.locals || {};
|
|
// The current Ghost version
|
|
res.locals.version = ghostVersion.full;
|
|
// The current Ghost version, but only major.minor
|
|
res.locals.safeVersion = ghostVersion.safe;
|
|
// relative path from the URL
|
|
res.locals.relativeUrl = req.path;
|
|
// make ghost api version available for the theme + routing
|
|
res.locals.apiVersion = bridge.getFrontendApiVersion();
|
|
|
|
next();
|
|
};
|