Ghost/core/server/web/admin/controller.js
Sam Lord 35e51e364b Switch to @tryghost/debug, remove ghost-ignition
no issue
The only pieces of Ghost-Ignition used in Ghost were debug and
logging. Both of these modules have been superceded by the Framework
monorepo, and all usages of Ignition have now been removed, replaced
with @tryghost/debug and @tryghost/logging.
2021-06-15 17:24:22 +01:00

30 lines
948 B
JavaScript

const debug = require('@tryghost/debug')('web:admin:controller');
const path = require('path');
const config = require('../../../shared/config');
const updateCheck = require('../../update-check');
/**
* @description Admin controller to handle /ghost/ requests.
*
* Every request to the admin panel will re-trigger the update check service.
*
* @param req
* @param res
*/
module.exports = function adminController(req, res) {
debug('index called');
// CASE: trigger update check unit and let it run in background, don't block the admin rendering
updateCheck();
const defaultTemplate = config.get('env') === 'production' ? 'default-prod.html' : 'default.html';
const templatePath = path.resolve(config.get('paths').adminViews, defaultTemplate);
const headers = {};
if (config.get('adminFrameProtection')) {
headers['X-Frame-Options'] = 'sameorigin';
}
res.sendFile(templatePath, {headers});
};