how to use passportjs middleware in a restify application

Viewed 122

I am trying to use passport.js to set up authorization in an api. I am having trouble checking if a user is already logged. In expressjs I would do something like:

router.get('/is_logged_in',
            passport.authenticate('jwt', { session: false }),  
            function (req, res, err) {
            ...
            }

that is, in expressjs you can add the middleware passport.authenticate(...),

Can this be done with restify?, for instance if I have the route:

server.get('/is_logged_in', (req, res, next) => {
  ...
});

Where do I put the middleware? (or is this supposed to be done differently?) I can not add it as a second parameter for what I understand.

0 Answers
Related