Introduce dependency injection
Inject hard-coded database clients, HTTP clients, and config values as parameters. Shows how the resulting code becomes trivially testable with mocks.
Preview
Copy prompt
Refactor the following code to apply the dependency injection pattern: [Paste code]. Identify every hard-coded dependency such as database clients, HTTP clients, third-party SDKs, and configuration values. Extract each one as a constructor parameter or function argument with a clear interface or type annotation. Update all call sites accordingly, and show a concrete example of how the refactored code can be tested in isolation using mocks or stubs.
More
Refactoring
Prompts
