middleware/guardMiddleware.js
// a middleware that protects endpoints from not being logged in
a middleware that protects endpoints from not being logged in
a middleware that protects endpoints from not being logged in
function guardMiddleware(req, res, next) {
    if (req.session && req.session.userID) {
        return next();
    } else {
        return res.redirect('/');
    };
}
function guardMiddleware ( req , res , next ) { if ( req . session && req . session . userID ) { return next ( ) ; } else { return res . redirect ( '/' ) ; } ; }
a middleware that protects endpoints from not being logged in
a middleware that protects endpoints from not being logged in