Remove a duplication in api routes