In mine application using inversify for DI conteinerisation
have a abstract class
@injectable()
export abstract class Name {
tableName: string;
constructor(
@inject("DatabaseService") public db: DatabaseService,
@inject("GenesisApiService") public api: GenesisApiService
) {}
abstract fullSync(accountId: number): Promise<void>;
abstract incrementalSync(accountId: number): Promise<void>;
}
also have class which one extends this Abstract class
@injectable()
export class ServiceName extends Name {
tableName = "Name";
constructor(
@inject("ServiceName") db: ServiceName,
@inject("Service2Name") api: Service2Name
) {
super(ServiceName, Service2Name);
}
async fullSync(accountId: number): Promise<void> {
const apiUrl = "/servlet/rs/v1/schedule/fetch/incrementalSync?authToken=";
const result = await this.api.get(apiUrl);
console.log("result", result);
}
async incrementalSync(accountId: number): Promise<void> {
return null;
}
}
after im containerized like in documentations
import "reflect-metadata";
import { Container } from "inversify";
import { ServiceName } from "./services/ServiceName/ServiceName";
export const container = new Container({
autoBindInjectable: true,
skipBaseClassChecks: true,
});
container.bind<ServiceName>("ServiceName").to(ServiceName);
after tryng to invoke service methods
import { container } from "../ioc";
import { GenesisApiService } from "../services/genesis-api";
export const ServiceName = async () => {
try {
console.log("@@@@@@@@@@@@@1");
const service = container.get<ServiceName>("ServiceName");
await service.get("123321");
} catch (error) {
console.log("error", error);
}
};
ServiceName();
and getting this error
Error: No matching bindings found for serviceIdentifier: String