Exclude specified route from a middleware
<p>I have this middleware that check every routes for user session. This just simply do if user logged in, go to next function.</p>

<pre><code>router.use(function(req, res, next){
    if(!req.user){
        res.redirect('/login');
     }else{
        res.locals.username = req.user.username;
        return next();
     }
});
</code></pre>

<p>But how to exclude it for certain route? For example I want to do a public API within my app also. Like example.com/api/items should not check for user login session.</p>