Update lib/middleware.js