modularize middleware.js