mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
refs https://linear.app/tryghost/issue/CORE-104/decouple-frontend-routing-events-from-urlserver-events - URL module is part of the backend heavily dependent on the model and fits perfectly here. Frontend should get the data it needs by passing a URL manager instance to it
25 lines
787 B
JavaScript
25 lines
787 B
JavaScript
const errors = require('@tryghost/errors');
|
|
const config = require('../../../../shared/config');
|
|
const tpl = require('@tryghost/tpl');
|
|
const urlService = require('../../../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();
|
|
};
|