2021-06-16 09:36:58 +01:00
|
|
|
const ghostVersion = require('@tryghost/version');
|
2016-10-10 20:14:32 +01:00
|
|
|
|
|
|
|
// ### 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;
|
2022-04-06 11:40:28 +01:00
|
|
|
// @TODO: remove
|
|
|
|
res.locals.apiVersion = 'canary';
|
2016-10-10 20:14:32 +01:00
|
|
|
|
|
|
|
next();
|
|
|
|
};
|