Refactoring using service for database & user's repositories endpoint