in my middleware folder, I have a file called auth.js.
In this file, I have this function:
function authCheck () {
if (req.session.loggedin) {
return;
} else {
req.session.destory();
res.redirect('/login')
}
}
I need to export it, and then use it in my other files, so then I would need to import it inside of my root directory app.js file, and my routes folder, those js files there.
I basically want to do this:
app.get('/index', authCheck, (req, res) => {
.....
}
how do I do this?