Ghost/core/app.js

23 lines
692 B
JavaScript
Raw Normal View History

const express = require('./shared/express');
const rootApp = express('root');
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);
};
rootApp.enable('maintenance');
rootApp.use(maintenanceMiddleware);
module.exports = rootApp;