middleware and server setup