Ghost/core/server/web/admin/controller.js
Naz 88564751f9 Removed duplicate update check error hanlindg
refs https://github.com/TryGhost/Team/issues/726

- Update check service is self contained and handles errors through logging internally. There is no visible upside to do the same logging in multiple places
2021-05-26 15:52:24 +04:00

30 lines
953 B
JavaScript

const debug = require('ghost-ignition').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});
};