templating schema and middleware