Sure, you do that where you declare your custom route.
function renderSink(req, res, next) {
if (!req.uid) return res.redirect('/login');
// Do normal stuff.
res.render('demo', someData);
}
module.exports = function(app, middleware, controllers) {
app.get('/demo', middleware.buildHeader, renderSink);
app.get('/api/demo', renderSink);
};
More info here: http://expressjs.com/4x/api.html#res.redirect