move middleware to config
fix module name for templates