I have a HttpService which is not injectable. It implements basic methods such as get, post etc and receives baseUrl as constructor argument to then create axios instance:
export class HttpService {
#instance: AxiosInstance;
constructor(baseURL: string) {
this.#instance = axios.create({ baseURL });
}
}
Then I can create new more specific http client based in HttpService:
export class DreamClient extends HttpService {
constructor(private readonly configService: ConfigService) {
super(configService.DREAM_URL.toString());
}
}
But now I want to add request and response interceptors in my base HttpService to be able to log outgoing requests. For that I need to inject winston logger which I cannot do since HttpService is not injectable. How can I make HttpService injectable (to be able to inject logger directly) while keeping extendability (to avoid passing down baseURL in every method)?