2013-11-25 21:31:18 +01: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 15:19:49 +02:00
|
|
|
var api = require('../api'),
|
|
|
|
bodyParser = require('body-parser'),
|
|
|
|
config = require('../config'),
|
2014-09-09 20:49:26 +02:00
|
|
|
crypto = require('crypto'),
|
2014-07-28 15:19:49 +02:00
|
|
|
errors = require('../errors'),
|
|
|
|
express = require('express'),
|
|
|
|
fs = require('fs'),
|
|
|
|
hbs = require('express-hbs'),
|
|
|
|
logger = require('morgan'),
|
|
|
|
middleware = require('./middleware'),
|
|
|
|
packageInfo = require('../../../package.json'),
|
|
|
|
path = require('path'),
|
|
|
|
routes = require('../routes'),
|
|
|
|
slashes = require('connect-slashes'),
|
|
|
|
storage = require('../storage'),
|
|
|
|
url = require('url'),
|
|
|
|
_ = require('lodash'),
|
|
|
|
passport = require('passport'),
|
|
|
|
oauth = require('./oauth'),
|
|
|
|
oauth2orize = require('oauth2orize'),
|
2014-09-19 18:17:58 +02:00
|
|
|
authStrategies = require('./auth-strategies'),
|
2014-07-28 15:19:49 +02:00
|
|
|
utils = require('../utils'),
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp,
|
2014-07-28 15:19:49 +02:00
|
|
|
setupMiddleware;
|
2013-11-12 07:03:25 +01: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 || {};
|
|
|
|
res.locals.version = packageInfo.version;
|
2014-08-23 22:42:44 +02:00
|
|
|
// relative path from the URL
|
|
|
|
res.locals.relativeUrl = req.path;
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2014-06-30 14:58:10 +02:00
|
|
|
next();
|
2013-11-12 07:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ### Activate Theme
|
|
|
|
// Helper for manageAdminAndTheme
|
2013-12-06 09:51:35 +01:00
|
|
|
function activateTheme(activeTheme) {
|
2013-12-02 00:31:55 +01:00
|
|
|
var hbsOptions,
|
2014-07-17 16:33:21 +02:00
|
|
|
themePartials = path.join(config.paths.themePath, activeTheme, 'partials');
|
2013-11-12 07:03:25 +01:00
|
|
|
|
|
|
|
// clear the view cache
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.cache = {};
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2013-12-02 00:31:55 +01:00
|
|
|
// set view engine
|
2014-09-10 06:06:24 +02:00
|
|
|
hbsOptions = {partialsDir: [config.paths.helperTemplates]};
|
2014-01-14 00:11:59 +01:00
|
|
|
|
|
|
|
fs.stat(themePartials, function (err, stats) {
|
2013-12-02 00:31:55 +01:00
|
|
|
// Check that the theme has a partials directory before trying to use it
|
2014-01-14 00:11:59 +01:00
|
|
|
if (!err && stats && stats.isDirectory()) {
|
|
|
|
hbsOptions.partialsDir.push(themePartials);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.engine('hbs', hbs.express3(hbsOptions));
|
2013-12-02 00:31:55 +01:00
|
|
|
|
2013-11-12 07:03:25 +01:00
|
|
|
// Update user error template
|
2014-03-26 21:43:16 +01:00
|
|
|
errors.updateActiveTheme(activeTheme);
|
2014-04-12 05:46:15 +02:00
|
|
|
|
|
|
|
// Set active theme variable on the express server
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.set('activeTheme', activeTheme);
|
2013-11-12 07:03:25 +01:00
|
|
|
}
|
2014-08-08 18:17:07 +02:00
|
|
|
// ### decideIsAdmin Middleware
|
2013-11-12 07:03:25 +01: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 18:17:07 +02:00
|
|
|
function decideIsAdmin(req, res, next) {
|
2014-08-23 22:42:44 +02:00
|
|
|
res.isAdmin = req.url.lastIndexOf('/ghost/', 0) === 0;
|
2014-08-08 18:17:07 +02:00
|
|
|
next();
|
|
|
|
}
|
2013-11-17 19:40:26 +01:00
|
|
|
|
2014-08-08 18:17:07 +02:00
|
|
|
// ### configHbsForContext Middleware
|
|
|
|
// Setup handlebars for the current context (admin or theme)
|
|
|
|
function configHbsForContext(req, res, next) {
|
2014-09-16 23:02:31 +02: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 07:03:25 +01:00
|
|
|
}
|
2014-04-12 05:46:15 +02:00
|
|
|
|
2014-09-16 23:02:31 +02:00
|
|
|
hbs.updateTemplateOptions({data: {blog: themeData}});
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.set('views', path.join(config.paths.themePath, blogApp.get('activeTheme')));
|
2014-09-16 23:02:31 +02:00
|
|
|
|
2014-04-12 05:46:15 +02: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 18:17:58 +02:00
|
|
|
// Updates the blogApp's activeTheme variable and subsequently
|
2014-04-12 05:46:15 +02: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 14:41:19 +02:00
|
|
|
api.settings.read({context: {internal: true}, key: 'activeTheme'}).then(function (response) {
|
2014-04-28 01:28:50 +02:00
|
|
|
var activeTheme = response.settings[0];
|
2013-12-06 09:51:35 +01:00
|
|
|
// Check if the theme changed
|
2014-09-19 18:17:58 +02:00
|
|
|
if (activeTheme.value !== blogApp.get('activeTheme')) {
|
2013-12-06 09:51:35 +01:00
|
|
|
// Change theme
|
2014-07-17 16:33:21 +02:00
|
|
|
if (!config.paths.availableThemes.hasOwnProperty(activeTheme.value)) {
|
2013-12-06 09:51:35 +01:00
|
|
|
if (!res.isAdmin) {
|
|
|
|
// Throw an error if the theme is not available, but not on the admin UI
|
2014-01-24 23:14:56 +01:00
|
|
|
return errors.throwError('The currently active theme ' + activeTheme.value + ' is missing.');
|
2013-12-06 09:51:35 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
activateTheme(activeTheme.value);
|
2013-11-12 07:03:25 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-06 09:51:35 +01:00
|
|
|
next();
|
2014-08-17 08:17:23 +02:00
|
|
|
}).catch(function (err) {
|
2014-01-24 23:14:56 +01: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 18:17:58 +02:00
|
|
|
blogApp.engine('hbs', hbs.express3());
|
2014-01-24 23:14:56 +01:00
|
|
|
next(err);
|
2013-12-06 09:51:35 +01:00
|
|
|
});
|
2013-11-12 07:03:25 +01:00
|
|
|
}
|
|
|
|
|
2014-06-25 14:12:48 +02:00
|
|
|
// Redirect to setup if no user exists
|
|
|
|
function redirectToSetup(req, res, next) {
|
|
|
|
/*jslint unparam:true*/
|
|
|
|
|
2014-07-11 14:17:09 +02:00
|
|
|
api.authentication.isSetup().then(function (exists) {
|
2014-09-16 23:02:31 +02:00
|
|
|
if (!exists.setup[0].status && !req.path.match(/\/setup\//)) {
|
2014-07-17 16:33:21 +02:00
|
|
|
return res.redirect(config.paths.subdir + '/ghost/setup/');
|
2014-06-25 14:12:48 +02:00
|
|
|
}
|
|
|
|
next();
|
2014-08-17 08:17:23 +02:00
|
|
|
}).catch(function (err) {
|
2014-06-25 14:12:48 +02:00
|
|
|
return next(new Error(err));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-08-23 18:23:34 +02:00
|
|
|
// Detect uppercase in req.path
|
|
|
|
function uncapitalise(req, res, next) {
|
2014-08-26 23:07:03 +02:00
|
|
|
var pathToTest = req.path,
|
2014-08-29 21:48:58 +02:00
|
|
|
isSignupOrReset = req.path.match(/(\/ghost\/(signup|reset)\/)/i),
|
2014-09-01 15:39:53 +02:00
|
|
|
isAPI = req.path.match(/(\/ghost\/api\/v[\d\.]+\/.*?\/)/i);
|
2014-08-26 23:07:03 +02:00
|
|
|
|
|
|
|
if (isSignupOrReset) {
|
|
|
|
pathToTest = isSignupOrReset[1];
|
|
|
|
}
|
2014-09-10 06:06:24 +02:00
|
|
|
|
2014-08-29 21:48:58 +02:00
|
|
|
// Do not lowercase anything after /api/v0.1/ to protect :key/:slug
|
|
|
|
if (isAPI) {
|
|
|
|
pathToTest = isAPI[1];
|
|
|
|
}
|
2014-08-26 23:07:03 +02:00
|
|
|
|
|
|
|
if (/[A-Z]/.test(pathToTest)) {
|
2014-08-23 18:23:34 +02:00
|
|
|
res.set('Cache-Control', 'public, max-age=' + utils.ONE_YEAR_S);
|
2014-08-26 23:07:03 +02:00
|
|
|
res.redirect(301, req.url.replace(pathToTest, pathToTest.toLowerCase()));
|
2014-08-23 18:23:34 +02:00
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 17:05:45 +01:00
|
|
|
function isSSLrequired(isAdmin) {
|
2014-07-17 16:33:21 +02:00
|
|
|
var forceSSL = url.parse(config.url).protocol === 'https:' ? true : false,
|
|
|
|
forceAdminSSL = (isAdmin && config.forceAdminSSL);
|
2013-12-19 17:05:45 +01:00
|
|
|
if (forceSSL || forceAdminSSL) {
|
|
|
|
return true;
|
2013-12-09 20:41:19 +01:00
|
|
|
}
|
2013-12-19 17:05:45 +01:00
|
|
|
return false;
|
2013-12-09 20:41:19 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 17:05:45 +01:00
|
|
|
// Check to see if we should use SSL
|
|
|
|
// and redirect if needed
|
2013-12-09 20:41:19 +01:00
|
|
|
function checkSSL(req, res, next) {
|
2013-12-19 17:05:45 +01:00
|
|
|
if (isSSLrequired(res.isAdmin)) {
|
2014-01-26 23:00:50 +01:00
|
|
|
if (!req.secure) {
|
2014-07-17 16:33:21 +02:00
|
|
|
var forceAdminSSL = config.forceAdminSSL,
|
2014-02-22 02:25:31 +01:00
|
|
|
redirectUrl;
|
|
|
|
|
|
|
|
// Check if forceAdminSSL: { redirect: false } is set, which means
|
|
|
|
// we should just deny non-SSL access rather than redirect
|
|
|
|
if (forceAdminSSL && forceAdminSSL.redirect !== undefined && !forceAdminSSL.redirect) {
|
2014-09-18 10:32:18 +02:00
|
|
|
return res.sendStatus(403);
|
2014-02-22 02:25:31 +01:00
|
|
|
}
|
|
|
|
|
2014-07-17 16:33:21 +02:00
|
|
|
redirectUrl = url.parse(config.urlSSL || config.url);
|
2013-12-19 17:05:45 +01:00
|
|
|
return res.redirect(301, url.format({
|
|
|
|
protocol: 'https:',
|
2014-02-22 02:25:31 +01:00
|
|
|
hostname: redirectUrl.hostname,
|
|
|
|
port: redirectUrl.port,
|
2013-12-19 17:05:45 +01:00
|
|
|
pathname: req.path,
|
|
|
|
query: req.query
|
|
|
|
}));
|
|
|
|
}
|
2013-12-09 20:41:19 +01:00
|
|
|
}
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
|
2014-09-09 20:49:26 +02:00
|
|
|
// ### ServeSharedFile Middleware
|
|
|
|
// Handles requests to robots.txt and favicon.ico (and caches them)
|
|
|
|
function serveSharedFile(file, type, maxAge) {
|
|
|
|
var content,
|
|
|
|
filePath = path.join(config.paths.corePath, 'shared', file);
|
2014-03-09 10:28:58 +01:00
|
|
|
|
2014-09-09 20:49:26 +02:00
|
|
|
return function serveSharedFile(req, res, next) {
|
|
|
|
if (req.url === path.join('/', file)) {
|
2014-03-09 10:28:58 +01: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-04-28 22:42:38 +02:00
|
|
|
|
2014-03-09 10:28:58 +01:00
|
|
|
content = {
|
|
|
|
headers: {
|
2014-09-09 20:49:26 +02:00
|
|
|
'Content-Type': type,
|
2014-03-09 10:28:58 +01:00
|
|
|
'Content-Length': buf.length,
|
2014-09-09 20:49:26 +02:00
|
|
|
ETag: '"' + crypto.createHash('md5').update(buf, 'utf8').digest('hex') + '"',
|
|
|
|
'Cache-Control': 'public, max-age=' + maxAge
|
2014-03-09 10:28:58 +01:00
|
|
|
},
|
|
|
|
body: buf
|
|
|
|
};
|
|
|
|
res.writeHead(200, content.headers);
|
|
|
|
res.end(content.body);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-09-19 18:17:58 +02:00
|
|
|
setupMiddleware = function (blogAppInstance, adminApp) {
|
2014-07-17 16:33:21 +02:00
|
|
|
var logging = config.logging,
|
|
|
|
corePath = config.paths.corePath,
|
2014-06-30 14:58:10 +02:00
|
|
|
oauthServer = oauth2orize.createServer();
|
|
|
|
|
|
|
|
// silence JSHint without disabling unused check for the whole file
|
|
|
|
authStrategies = authStrategies;
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2013-12-06 15:13:15 +01:00
|
|
|
// Cache express server instance
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp = blogAppInstance;
|
|
|
|
middleware.cacheBlogApp(blogApp);
|
2014-06-30 14:58:10 +02:00
|
|
|
middleware.cacheOauthServer(oauthServer);
|
2014-08-05 12:58:58 +02:00
|
|
|
oauth.init(oauthServer, middleware.resetSpamCounter);
|
2013-12-06 15:13:15 +01:00
|
|
|
|
2014-01-26 23:00:50 +01:00
|
|
|
// Make sure 'req.secure' is valid for proxied requests
|
|
|
|
// (X-Forwarded-Proto header will be checked, if present)
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.enable('trust proxy');
|
2014-01-26 23:00:50 +01:00
|
|
|
|
2013-11-12 07:03:25 +01:00
|
|
|
// Logging configuration
|
2014-02-10 22:07:11 +01:00
|
|
|
if (logging !== false) {
|
2014-09-19 18:17:58 +02:00
|
|
|
if (blogApp.get('env') !== 'development') {
|
|
|
|
blogApp.use(logger('combined', logging));
|
2014-02-10 22:07:11 +01:00
|
|
|
} else {
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(logger('dev', logging));
|
2014-02-10 22:07:11 +01:00
|
|
|
}
|
2013-11-12 07:03:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Favicon
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(serveSharedFile('favicon.ico', 'image/x-icon', utils.ONE_DAY_S));
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2013-12-31 00:13:25 +01:00
|
|
|
// Static assets
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use('/shared', express['static'](path.join(corePath, '/shared'), {maxAge: utils.ONE_HOUR_MS}));
|
|
|
|
blogApp.use('/content/images', storage.getStorage().serve());
|
|
|
|
blogApp.use('/ghost/scripts', express['static'](path.join(corePath, '/built/scripts'), {maxAge: utils.ONE_YEAR_MS}));
|
|
|
|
blogApp.use('/public', express['static'](path.join(corePath, '/built/public'), {maxAge: utils.ONE_YEAR_MS}));
|
2013-11-12 07:03:25 +01:00
|
|
|
|
|
|
|
// First determine whether we're serving admin or theme content
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(decideIsAdmin);
|
|
|
|
blogApp.use(updateActiveTheme);
|
|
|
|
blogApp.use(configHbsForContext);
|
2013-11-12 07:03:25 +01:00
|
|
|
|
|
|
|
// Admin only config
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use('/ghost', express['static'](path.join(corePath, '/client/assets'), {maxAge: utils.ONE_YEAR_MS}));
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2014-01-26 23:21:24 +01: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!
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(checkSSL);
|
|
|
|
adminApp.set('views', config.paths.adminViews);
|
2014-01-26 23:21:24 +01:00
|
|
|
|
2013-11-12 07:03:25 +01:00
|
|
|
// Theme only config
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(middleware.staticTheme());
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2014-03-09 10:28:58 +01:00
|
|
|
// Serve robots.txt if not found in theme
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(serveSharedFile('robots.txt', 'text/plain', utils.ONE_YEAR_S));
|
2014-03-09 10:28:58 +01:00
|
|
|
|
2014-08-23 22:42:44 +02:00
|
|
|
// Add in all trailing slashes, properly include the subdir path
|
|
|
|
// in the redirect.
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(slashes(true, {
|
2014-08-23 22:42:44 +02:00
|
|
|
headers: {
|
|
|
|
'Cache-Control': 'public, max-age=' + utils.ONE_YEAR_S
|
|
|
|
},
|
|
|
|
base: config.paths.subdir
|
|
|
|
}));
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(uncapitalise);
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2013-12-31 00:13:25 +01:00
|
|
|
// Body parsing
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(bodyParser.json());
|
|
|
|
blogApp.use(bodyParser.urlencoded({extended: true}));
|
2013-11-17 19:40:26 +01:00
|
|
|
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(passport.initialize());
|
2013-11-12 07:03:25 +01:00
|
|
|
|
2014-02-14 11:00:11 +01:00
|
|
|
// ### Caching
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(middleware.cacheControl('public'));
|
|
|
|
adminApp.use(middleware.cacheControl('private'));
|
2014-02-14 11:00:11 +01:00
|
|
|
|
2014-06-30 14:58:10 +02:00
|
|
|
// enable authentication
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(middleware.authenticate);
|
2014-02-14 11:00:11 +01:00
|
|
|
|
2013-11-12 07:03:25 +01:00
|
|
|
// local data
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(ghostLocals);
|
2014-04-28 22:58:18 +02:00
|
|
|
|
2013-12-31 00:13:25 +01:00
|
|
|
// ### Routing
|
2014-04-12 05:46:15 +02:00
|
|
|
// Set up API routes
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(routes.apiBaseUri, routes.api(middleware));
|
2014-04-12 05:46:15 +02:00
|
|
|
|
2014-09-16 23:02:31 +02:00
|
|
|
// Mount admin express app to /ghost and set up routes
|
2014-09-19 18:17:58 +02:00
|
|
|
adminApp.use(middleware.redirectToSetup);
|
|
|
|
adminApp.use(routes.admin());
|
|
|
|
blogApp.use('/ghost', adminApp);
|
2014-04-12 05:46:15 +02:00
|
|
|
|
|
|
|
// Set up Frontend routes
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(routes.frontend());
|
2013-11-12 07:03:25 +01:00
|
|
|
|
|
|
|
// ### Error handling
|
|
|
|
// 404 Handler
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(errors.error404);
|
2013-11-12 07:03:25 +01:00
|
|
|
|
|
|
|
// 500 Handler
|
2014-09-19 18:17:58 +02:00
|
|
|
blogApp.use(errors.error500);
|
2013-11-12 07:03:25 +01:00
|
|
|
};
|
|
|
|
|
2014-07-14 14:29:45 +02:00
|
|
|
module.exports = setupMiddleware;
|
2013-11-12 07:03:25 +01:00
|
|
|
// Export middleware functions directly
|
2013-11-17 19:40:26 +01:00
|
|
|
module.exports.middleware = middleware;
|
2013-12-06 15:13:15 +01:00
|
|
|
// Expose middleware functions in this file as well
|
2014-06-25 14:12:48 +02:00
|
|
|
module.exports.middleware.redirectToSetup = redirectToSetup;
|