added middleware.js to /lib