Categories
express model-view-controller node.js passport.js

Where to put PassportJs local strategy in an express application?

I have an expressjs application and I am trying to get passportjs set up for simple user authentication. My routes are stored in a separate file. I have a routes file (users.js) for all my user related routes. I also have a controller file called UserController that contains all the functions for user related stuff and deals with my database.

My question is, where should I declare the passport strategy so that it follows the MVC pattern?

Putting it in any other file besides the routes file doesn’t work as it does not have the passport object.