title: Restricting access to static files in ExpressJS
body: <p>I have a server that routes pretty much everything through middleware to check to see if you're logged in, but that only works for routes. I would also like it to work with static files in the <code>public</code> directory. How would I go about doing that?</p>
  
  <p><strong>update</strong>: it's better to not worry about protecting what's in the <code>/public</code> folder because express offers a <code>res.download(...)</code> feature. <a href="https://github.com/visionmedia/express/tree/master/examples/downloads" rel="noreferrer">Example on the Express.JS GitHub page</a></p>