app.js
/**
 * Provides sidebar data needed for view layout.
 */
Provides sidebar data needed for view layout.
Provides sidebar data needed for view layout .
function handleSidebar(req, res, next) {
  User.findByUsername('ManInTheBox', function (err, user) {
    if (err) return next(err);
    Post.findByAuthor(user._id, function (err, authorPosts) {
      if (err) return next(err);
      Post.findNewest(function (err, newestPosts) {
        if (err) return next(err);
        req.sidebar = {
          data: {
            user: user,
            posts: {
              author: authorPosts,
              newest: newestPosts
            }
          }
        };
        next();
      });
    });
  });
}
function handleSidebar ( req , res , next ) { User . findByUsername ( 'ManInTheBox' , function ( err , user ) { if ( err ) return next ( err ) ; Post . findByAuthor ( user . _id , function ( err , authorPosts ) { if ( err ) return next ( err ) ; Post . findNewest ( function ( err , newestPosts ) { if ( err ) return next ( err ) ; req . sidebar = { data : { user : user , posts : { author : authorPosts , newest : newestPosts } } } ; next ( ) ; } ) ; } ) ; } ) ; }
Provides sidebar data needed for view layout.
Provides sidebar data needed for view layout .