[lib] Move middleware documentation to lib/middleware.js