configure middleware and error handling