I am pretty new to restify and nodejs in general. I am attempting to build a rest api using restify and nodejs, and I need to implement a token-based authentication layer, or middleware if you will. On login, I generate a jwt token, which I save to a database, and I would like to validate the users token before allowing them to access particular endpoints. I have found a lot of information on how to do this using the Express framework, similar to this example below
function middlewareHandler(req, res, next) {
console.log("execute middle ware");
next();
}
app.get('/', middlewareHandler, function (req, res) {
console.log("end middleware function");
res.send("page render finished");
});
but so far I haven't been able to find anything similar for Restify. Can anyone please provide me some guidance on how to do this?