Refactoring saveApiKey out of route.