2013-11-26 00:31:18 +04:00
|
|
|
// # Custom Middleware
|
|
|
|
// The following custom middleware functions cannot yet be unit tested, and as such are kept separate from
|
|
|
|
// the testable custom middleware functions in middleware.js
|
|
|
|
|
2014-07-28 17:19:49 +04:00
|
|
|
var api = require('../api'),
|
|
|
|
bodyParser = require('body-parser'),
|
|
|
|
config = require('../config'),
|
2014-09-09 22:49:26 +04:00
|
|
|
crypto = require('crypto'),
|
2014-07-28 17:19:49 +04:00
|
|
|
errors = require('../errors'),
|
|
|
|
express = require('express'),
|
|
|
|
fs = require('fs'),
|
|
|
|
hbs = require('express-hbs'),
|
|
|
|
logger = require('morgan'),
|
|
|
|
middleware = require('./middleware'),
|
|
|
|
path = require('path'),
|
|
|
|
routes = require('../routes'),
|
|
|
|
slashes = require('connect-slashes'),
|
|
|
|
storage = require('../storage'),
|
|
|
|
_ = require('lodash'),
|
|
|
|
passport = require('passport'),
|
|
|
|
oauth = require('./oauth'),
|
|
|
|
oauth2orize = require('oauth2orize'),
|
2014-09-19 20:17:58 +04:00
|
|
|
authStrategies = require('./auth-strategies'),
|
2014-07-28 17:19:49 +04:00
|
|
|
utils = require('../utils'),
|
2015-03-24 23:23:23 +03:00
|
|
|
sitemapHandler = require('../data/xml/sitemap/handler'),
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp,
|
2014-07-28 17:19:49 +04:00
|
|
|
setupMiddleware;
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// ##Custom Middleware
|
|
|
|
|
|
|
|
// ### GhostLocals Middleware
|
|
|
|
// Expose the standard locals that every external page should have available,
|
|
|
|
// separating between the theme and the admin
|
|
|
|
function ghostLocals(req, res, next) {
|
|
|
|
// Make sure we have a locals value.
|
|
|
|
res.locals = res.locals || {};
|
2014-11-28 20:47:32 +03:00
|
|
|
res.locals.version = config.ghostVersion;
|
2015-04-07 19:34:50 +03:00
|
|
|
res.locals.safeVersion = config.ghostVersion.match(/^(\d+\.)?(\d+)/)[0];
|
2014-08-24 00:42:44 +04:00
|
|
|
// relative path from the URL
|
|
|
|
res.locals.relativeUrl = req.path;
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2014-06-30 16:58:10 +04:00
|
|
|
next();
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// ### Activate Theme
|
|
|
|
// Helper for manageAdminAndTheme
|
2013-12-06 12:51:35 +04:00
|
|
|
function activateTheme(activeTheme) {
|
2013-12-02 03:31:55 +04:00
|
|
|
var hbsOptions,
|
2014-07-17 18:33:21 +04:00
|
|
|
themePartials = path.join(config.paths.themePath, activeTheme, 'partials');
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// clear the view cache
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.cache = {};
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2013-12-02 03:31:55 +04:00
|
|
|
// set view engine
|
2015-03-10 18:52:00 +03:00
|
|
|
hbsOptions = {
|
|
|
|
partialsDir: [config.paths.helperTemplates],
|
|
|
|
onCompile: function (exhbs, source) {
|
|
|
|
return exhbs.handlebars.compile(source, {preventIndent: true});
|
|
|
|
}
|
|
|
|
};
|
2014-01-14 03:11:59 +04:00
|
|
|
|
|
|
|
fs.stat(themePartials, function (err, stats) {
|
2013-12-02 03:31:55 +04:00
|
|
|
// Check that the theme has a partials directory before trying to use it
|
2014-01-14 03:11:59 +04:00
|
|
|
if (!err && stats && stats.isDirectory()) {
|
|
|
|
hbsOptions.partialsDir.push(themePartials);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.engine('hbs', hbs.express3(hbsOptions));
|
2013-12-02 03:31:55 +04:00
|
|
|
|
2013-11-12 10:03:25 +04:00
|
|
|
// Update user error template
|
2014-03-27 00:43:16 +04:00
|
|
|
errors.updateActiveTheme(activeTheme);
|
2014-04-12 07:46:15 +04:00
|
|
|
|
|
|
|
// Set active theme variable on the express server
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.set('activeTheme', activeTheme);
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
2014-08-08 20:17:07 +04:00
|
|
|
// ### decideIsAdmin Middleware
|
2013-11-12 10:03:25 +04:00
|
|
|
// Uses the URL to detect whether this response should be an admin response
|
|
|
|
// This is used to ensure the right content is served, and is not for security purposes
|
2014-08-08 20:17:07 +04:00
|
|
|
function decideIsAdmin(req, res, next) {
|
2014-08-24 00:42:44 +04:00
|
|
|
res.isAdmin = req.url.lastIndexOf('/ghost/', 0) === 0;
|
2014-08-08 20:17:07 +04:00
|
|
|
next();
|
|
|
|
}
|
2013-11-17 22:40:26 +04:00
|
|
|
|
2014-08-08 20:17:07 +04:00
|
|
|
// ### configHbsForContext Middleware
|
|
|
|
// Setup handlebars for the current context (admin or theme)
|
|
|
|
function configHbsForContext(req, res, next) {
|
2014-09-17 01:02:31 +04:00
|
|
|
var themeData = config.theme;
|
|
|
|
if (req.secure && config.urlSSL) {
|
|
|
|
// For secure requests override .url property with the SSL version
|
|
|
|
themeData = _.clone(themeData);
|
|
|
|
themeData.url = config.urlSSL.replace(/\/$/, '');
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
2014-04-12 07:46:15 +04:00
|
|
|
|
2014-09-17 01:02:31 +04:00
|
|
|
hbs.updateTemplateOptions({data: {blog: themeData}});
|
2015-04-25 22:54:07 +03:00
|
|
|
|
|
|
|
if (config.paths.themePath && blogApp.get('activeTheme')) {
|
|
|
|
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
|
|
|
|
}
|
2014-09-17 01:02:31 +04:00
|
|
|
|
2014-04-12 07:46:15 +04:00
|
|
|
// Pass 'secure' flag to the view engine
|
|
|
|
// so that templates can choose 'url' vs 'urlSSL'
|
|
|
|
res.locals.secure = req.secure;
|
|
|
|
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ### updateActiveTheme
|
2014-09-19 20:17:58 +04:00
|
|
|
// Updates the blogApp's activeTheme variable and subsequently
|
2014-04-12 07:46:15 +04:00
|
|
|
// activates that theme's views with the hbs templating engine if it
|
|
|
|
// is not yet activated.
|
|
|
|
function updateActiveTheme(req, res, next) {
|
Refactor API arguments
closes #2610, refs #2697
- cleanup API index.js, and add docs
- all API methods take consistent arguments: object & options
- browse, read, destroy take options, edit and add take object and options
- the context is passed as part of options, meaning no more .call
everywhere
- destroy expects an object, rather than an id all the way down to the model layer
- route params such as :id, :slug, and :key are passed as an option & used
to perform reads, updates and deletes where possible - settings / themes
may need work here still
- HTTP posts api can find a post by slug
- Add API utils for checkData
2014-05-08 16:41:19 +04:00
|
|
|
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
|
2014-04-28 03:28:50 +04:00
|
|
|
var activeTheme = response.settings[0];
|
2015-04-25 22:54:07 +03:00
|
|
|
|
2013-12-06 12:51:35 +04:00
|
|
|
// Check if the theme changed
|
2014-09-19 20:17:58 +04:00
|
|
|
if (activeTheme.value !== blogApp.get('activeTheme')) {
|
2013-12-06 12:51:35 +04:00
|
|
|
// Change theme
|
2014-07-17 18:33:21 +04:00
|
|
|
if (!config.paths.availableThemes.hasOwnProperty(activeTheme.value)) {
|
2013-12-06 12:51:35 +04:00
|
|
|
if (!res.isAdmin) {
|
|
|
|
// Throw an error if the theme is not available, but not on the admin UI
|
2014-01-25 02:14:56 +04:00
|
|
|
return errors.throwError('The currently active theme ' + activeTheme.value + ' is missing.');
|
2015-04-25 22:54:07 +03:00
|
|
|
} else {
|
|
|
|
// At this point the activated theme is not present and the current
|
|
|
|
// request is for the admin client. In order to allow the user access
|
|
|
|
// to the admin client we set an hbs instance on the app so that middleware
|
|
|
|
// processing can continue.
|
|
|
|
blogApp.engine('hbs', hbs.express3());
|
|
|
|
errors.logWarn('The currently active theme "' + activeTheme.value + '" is missing.');
|
|
|
|
|
|
|
|
return next();
|
2013-12-06 12:51:35 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
activateTheme(activeTheme.value);
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
|
|
|
}
|
2013-12-06 12:51:35 +04:00
|
|
|
next();
|
2014-08-17 10:17:23 +04:00
|
|
|
}).catch(function (err) {
|
2014-01-25 02:14:56 +04:00
|
|
|
// Trying to start up without the active theme present, setup a simple hbs instance
|
|
|
|
// and render an error page straight away.
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.engine('hbs', hbs.express3());
|
2014-01-25 02:14:56 +04:00
|
|
|
next(err);
|
2013-12-06 12:51:35 +04:00
|
|
|
});
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
|
|
|
|
2014-06-25 16:12:48 +04:00
|
|
|
// Redirect to setup if no user exists
|
|
|
|
function redirectToSetup(req, res, next) {
|
|
|
|
/*jslint unparam:true*/
|
|
|
|
|
2014-07-11 16:17:09 +04:00
|
|
|
api.authentication.isSetup().then(function (exists) {
|
2014-09-17 01:02:31 +04:00
|
|
|
if (!exists.setup[0].status && !req.path.match(/\/setup\//)) {
|
2014-07-17 18:33:21 +04:00
|
|
|
return res.redirect(config.paths.subdir + '/ghost/setup/');
|
2014-06-25 16:12:48 +04:00
|
|
|
}
|
|
|
|
next();
|
2014-08-17 10:17:23 +04:00
|
|
|
}).catch(function (err) {
|
2014-06-25 16:12:48 +04:00
|
|
|
return next(new Error(err));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-08-23 20:23:34 +04:00
|
|
|
// Detect uppercase in req.path
|
|
|
|
function uncapitalise(req, res, next) {
|
2014-08-27 01:07:03 +04:00
|
|
|
var pathToTest = req.path,
|
2014-08-29 23:48:58 +04:00
|
|
|
isSignupOrReset = req.path.match(/(\/ghost\/(signup|reset)\/)/i),
|
2014-09-01 17:39:53 +04:00
|
|
|
isAPI = req.path.match(/(\/ghost\/api\/v[\d\.]+\/.*?\/)/i);
|
2014-08-27 01:07:03 +04:00
|
|
|
|
|
|
|
if (isSignupOrReset) {
|
|
|
|
pathToTest = isSignupOrReset[1];
|
|
|
|
}
|
2014-09-10 08:06:24 +04:00
|
|
|
|
2014-08-29 23:48:58 +04:00
|
|
|
// Do not lowercase anything after /api/v0.1/ to protect :key/:slug
|
|
|
|
if (isAPI) {
|
|
|
|
pathToTest = isAPI[1];
|
|
|
|
}
|
2014-08-27 01:07:03 +04:00
|
|
|
|
|
|
|
if (/[A-Z]/.test(pathToTest)) {
|
2014-08-23 20:23:34 +04:00
|
|
|
res.set('Cache-Control', 'public, max-age=' + utils.ONE_YEAR_S);
|
2014-08-27 01:07:03 +04:00
|
|
|
res.redirect(301, req.url.replace(pathToTest, pathToTest.toLowerCase()));
|
2014-08-23 20:23:34 +04:00
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-09 22:49:26 +04:00
|
|
|
// ### ServeSharedFile Middleware
|
|
|
|
// Handles requests to robots.txt and favicon.ico (and caches them)
|
|
|
|
function serveSharedFile(file, type, maxAge) {
|
|
|
|
var content,
|
2014-12-17 17:55:27 +03:00
|
|
|
filePath = path.join(config.paths.corePath, 'shared', file),
|
|
|
|
re = /(\{\{blog-url\}\})/g;
|
2014-03-09 13:28:58 +04:00
|
|
|
|
2014-09-09 22:49:26 +04:00
|
|
|
return function serveSharedFile(req, res, next) {
|
2014-09-25 14:00:51 +04:00
|
|
|
if (req.url === '/' + file) {
|
2014-03-09 13:28:58 +04:00
|
|
|
if (content) {
|
|
|
|
res.writeHead(200, content.headers);
|
|
|
|
res.end(content.body);
|
|
|
|
} else {
|
|
|
|
fs.readFile(filePath, function (err, buf) {
|
|
|
|
if (err) {
|
|
|
|
return next(err);
|
|
|
|
}
|
2014-12-16 23:22:31 +03:00
|
|
|
if (type === 'text/xsl' || type === 'text/plain') {
|
2014-12-17 17:55:27 +03:00
|
|
|
buf = buf.toString().replace(re, config.url.replace(/\/$/, ''));
|
2014-12-16 23:22:31 +03:00
|
|
|
}
|
2014-03-09 13:28:58 +04:00
|
|
|
content = {
|
|
|
|
headers: {
|
2014-09-09 22:49:26 +04:00
|
|
|
'Content-Type': type,
|
2014-03-09 13:28:58 +04:00
|
|
|
'Content-Length': buf.length,
|
2014-09-09 22:49:26 +04:00
|
|
|
ETag: '"' + crypto.createHash('md5').update(buf, 'utf8').digest('hex') + '"',
|
|
|
|
'Cache-Control': 'public, max-age=' + maxAge
|
2014-03-09 13:28:58 +04:00
|
|
|
},
|
|
|
|
body: buf
|
|
|
|
};
|
|
|
|
res.writeHead(200, content.headers);
|
|
|
|
res.end(content.body);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-09-19 20:17:58 +04:00
|
|
|
setupMiddleware = function (blogAppInstance, adminApp) {
|
2014-07-17 18:33:21 +04:00
|
|
|
var logging = config.logging,
|
|
|
|
corePath = config.paths.corePath,
|
2014-06-30 16:58:10 +04:00
|
|
|
oauthServer = oauth2orize.createServer();
|
|
|
|
|
|
|
|
// silence JSHint without disabling unused check for the whole file
|
|
|
|
authStrategies = authStrategies;
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2013-12-06 18:13:15 +04:00
|
|
|
// Cache express server instance
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp = blogAppInstance;
|
|
|
|
middleware.cacheBlogApp(blogApp);
|
2014-06-30 16:58:10 +04:00
|
|
|
middleware.cacheOauthServer(oauthServer);
|
2014-08-05 14:58:58 +04:00
|
|
|
oauth.init(oauthServer, middleware.resetSpamCounter);
|
2013-12-06 18:13:15 +04:00
|
|
|
|
2014-01-27 02:00:50 +04:00
|
|
|
// Make sure 'req.secure' is valid for proxied requests
|
|
|
|
// (X-Forwarded-Proto header will be checked, if present)
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.enable('trust proxy');
|
2014-01-27 02:00:50 +04:00
|
|
|
|
2013-11-12 10:03:25 +04:00
|
|
|
// Logging configuration
|
2014-02-11 01:07:11 +04:00
|
|
|
if (logging !== false) {
|
2014-09-19 20:17:58 +04:00
|
|
|
if (blogApp.get('env') !== 'development') {
|
|
|
|
blogApp.use(logger('combined', logging));
|
2014-02-11 01:07:11 +04:00
|
|
|
} else {
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(logger('dev', logging));
|
2014-02-11 01:07:11 +04:00
|
|
|
}
|
2013-11-12 10:03:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Favicon
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S));
|
2014-12-01 13:43:01 +03:00
|
|
|
blogApp.use(serveSharedFile('sitemap.xsl', 'text/xsl', utils.ONE_DAY_S));
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2013-12-31 03:13:25 +04:00
|
|
|
// Static assets
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use('/shared', express['static'](path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS}));
|
|
|
|
blogApp.use('/content/images', storage.getStorage().serve());
|
|
|
|
blogApp.use('/public', express['static'](path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS}));
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// First determine whether we're serving admin or theme content
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(decideIsAdmin);
|
|
|
|
blogApp.use(updateActiveTheme);
|
|
|
|
blogApp.use(configHbsForContext);
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// Admin only config
|
2015-03-08 20:09:57 +03:00
|
|
|
blogApp.use('/ghost', express['static'](config.paths.clientAssets, {maxAge: utils.ONE_YEAR_MS}));
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2014-01-27 02:21:24 +04:00
|
|
|
// Force SSL
|
|
|
|
// NOTE: Importantly this is _after_ the check above for admin-theme static resources,
|
|
|
|
// which do not need HTTPS. In fact, if HTTPS is forced on them, then 404 page might
|
|
|
|
// not display properly when HTTPS is not available!
|
2015-01-18 21:44:50 +03:00
|
|
|
blogApp.use(middleware.checkSSL);
|
2014-09-19 20:17:58 +04:00
|
|
|
adminApp.set('views', config.paths.adminViews);
|
2014-01-27 02:21:24 +04:00
|
|
|
|
2013-11-12 10:03:25 +04:00
|
|
|
// Theme only config
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(middleware.staticTheme());
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2014-03-09 13:28:58 +04:00
|
|
|
// Serve robots.txt if not found in theme
|
2014-09-25 14:00:51 +04:00
|
|
|
blogApp.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_HOUR_S));
|
2014-03-09 13:28:58 +04:00
|
|
|
|
2014-10-28 03:41:18 +03:00
|
|
|
// site map
|
|
|
|
sitemapHandler(blogApp);
|
|
|
|
|
2014-12-25 03:22:45 +03:00
|
|
|
// Add in all trailing slashes
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(slashes(true, {
|
2014-08-24 00:42:44 +04:00
|
|
|
headers: {
|
|
|
|
'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S
|
2014-12-25 03:22:45 +03:00
|
|
|
}
|
2014-08-24 00:42:44 +04:00
|
|
|
}));
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(uncapitalise);
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2013-12-31 03:13:25 +04:00
|
|
|
// Body parsing
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(bodyParser.json());
|
|
|
|
blogApp.use(bodyParser.urlencoded({extended: true}));
|
2013-11-17 22:40:26 +04:00
|
|
|
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(passport.initialize());
|
2013-11-12 10:03:25 +04:00
|
|
|
|
2014-02-14 14:00:11 +04:00
|
|
|
// ### Caching
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(middleware.cacheControl('public'));
|
|
|
|
adminApp.use(middleware.cacheControl('private'));
|
2014-09-25 13:35:28 +04:00
|
|
|
blogApp.use(routes.apiBaseUri, middleware.cacheControl('private'));
|
2014-02-14 14:00:11 +04:00
|
|
|
|
2014-06-30 16:58:10 +04:00
|
|
|
// enable authentication
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(middleware.authenticate);
|
2014-02-14 14:00:11 +04:00
|
|
|
|
2013-11-12 10:03:25 +04:00
|
|
|
// local data
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(ghostLocals);
|
2014-04-29 00:58:18 +04:00
|
|
|
|
2013-12-31 03:13:25 +04:00
|
|
|
// ### Routing
|
2014-04-12 07:46:15 +04:00
|
|
|
// Set up API routes
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(routes.apiBaseUri, routes.api(middleware));
|
2014-04-12 07:46:15 +04:00
|
|
|
|
2014-09-17 01:02:31 +04:00
|
|
|
// Mount admin express app to /ghost and set up routes
|
2014-09-19 20:17:58 +04:00
|
|
|
adminApp.use(middleware.redirectToSetup);
|
|
|
|
adminApp.use(routes.admin());
|
|
|
|
blogApp.use('/ghost', adminApp);
|
2014-04-12 07:46:15 +04:00
|
|
|
|
|
|
|
// Set up Frontend routes
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(routes.frontend());
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// ### Error handling
|
|
|
|
// 404 Handler
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(errors.error404);
|
2013-11-12 10:03:25 +04:00
|
|
|
|
|
|
|
// 500 Handler
|
2014-09-19 20:17:58 +04:00
|
|
|
blogApp.use(errors.error500);
|
2013-11-12 10:03:25 +04:00
|
|
|
};
|
|
|
|
|
2014-07-14 16:29:45 +04:00
|
|
|
module.exports = setupMiddleware;
|
2013-11-12 10:03:25 +04:00
|
|
|
// Export middleware functions directly
|
2013-11-17 22:40:26 +04:00
|
|
|
module.exports.middleware = middleware;
|
2013-12-06 18:13:15 +04:00
|
|
|
// Expose middleware functions in this file as well
|
2014-06-25 16:12:48 +04:00
|
|
|
module.exports.middleware.redirectToSetup = redirectToSetup;
|