title: Authentication middleware in Express NodeJS - Best practice
body: <p>I'm writing my first Express NodeJS app and I want to know what is the best practice when it comes to authentication middlewares?</p>
  
  <p>I'm using access tokens and cookies (which are composed from user id and some random bytes) for each new user, and for some routes I want only given users to have access to it. </p>
  
  <p>Is a good idea to access database from a middleware? Or where should I check if a given user has access to a given resource?</p>
  
  <p>Thank you!</p>