I am trying to replicate a middleware you might have in express on an azure function.
For example:
router.get('/protectedEndpoint', secured(), function (req, res) {
where the secured() function is a middleware that will send next() if valid.
the problem with azure is it is done in the style
module.exports = function (context) {
and i am unsure of how to run a middleware with next() in this
here is a dumb example of what that function may look like:
module.exports = function () {
return function secured (req, res, next) {
if (req.user) { return next(); }
req.session.returnTo = req.originalUrl;
res.redirect('/login');
};
};