mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 18:01:36 +03:00
213f0a4785
- 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
20 lines
761 B
JavaScript
20 lines
761 B
JavaScript
const ghostVersion = require('../../../lib/ghost-version');
|
|
const themeService = require('../../../../frontend/services/themes');
|
|
|
|
// ### 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 = themeService.getApiVersion();
|
|
|
|
next();
|
|
};
|