function checkAuth(req, res, next) {
if (req.user) {
console.log('checkAuth() is TRUE');
next();
} else {
console.log('checkAuth() is FALSE');
res.redirect('/');
}
}
app.get('/home', checkAuth, (req, res) => {
res.sendFile(__dirname + "/private/home.html")
});
app.use(...) - повесить глобальный middleware
app.get('/', () => здесь router specific middleware
)