Understanding connect middleware