0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/web/shared/middlewares/maintenance.js
Naz 6e075c78bf Moved URL service to backend
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
2021-10-19 07:29:09 +13:00

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();
};