move middleware to a config file