Ghost/core/server/web/shared/middlewares/maintenance.js
ozanuslan e2eef2a6d3 Replaced i18n.t w/ tpl in maintenance.js
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-05 14:37:46 +01:00

26 lines
799 B
JavaScript

const errors = require('@tryghost/errors');
const config = require('../../../../shared/config');
const tpl = require('@tryghost/tpl');
const urlService = require('../../../../frontend/services/url');
const messages = {
maintenance: 'Site is currently undergoing maintenance, please wait a moment then retry.',
maintenanceUrlService: 'Site is starting up, please wait a moment then retry.'
};
module.exports = function maintenance(req, res, next) {
if (config.get('maintenance').enabled) {
return next(new errors.MaintenanceError({
message: tpl(messages.maintenance)
}));
}
if (!urlService.hasFinished()) {
return next(new errors.MaintenanceError({
message: tpl(messages.maintenanceUrlService)
}));
}
next();
};