mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 22:02:11 +03:00
4b472615a8
- With the new boot finalised it's clearer to see where this needs to go - Update comments to add more clarity around what's happening and why - Cleaned up the version require, as this was prep for maybe using version via config, which won't work in MigratorConfig
26 lines
772 B
JavaScript
26 lines
772 B
JavaScript
const sentry = require('./shared/sentry');
|
|
const express = require('./shared/express');
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
// We never want middleware functions to be anonymous
|
|
const maintenanceMiddleware = (req, res, next) => {
|
|
if (!req.app.get('maintenance')) {
|
|
return next();
|
|
}
|
|
res.set({
|
|
'Cache-Control': 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0'
|
|
});
|
|
res.writeHead(503, {'content-type': 'text/html'});
|
|
fs.createReadStream(path.resolve(__dirname, './server/views/maintenance.html')).pipe(res);
|
|
};
|
|
|
|
const rootApp = express('root');
|
|
rootApp.use(sentry.requestHandler);
|
|
|
|
rootApp.enable('maintenance');
|
|
rootApp.use(maintenanceMiddleware);
|
|
|
|
module.exports = rootApp;
|