Skip to content

question: using typedi multiple projects #1487

@Zekhap

Description

@Zekhap

Right now i have my core project. Lets say it has this class.

@Service()
export class LoggerManager extends AbstractManager {}

and then my main project that is importing my core project with npm depencendy

@Service()
export class DatabaseManager extends AbstractManager {}

I have added reflect-metadata.
Everything is working...in its own project.

i cant do Container.get(LoggerManager); if im in my main project
but i can do Container.get(DatabaseManager);

i exported Container from my core project

console.log(MainContainer.handlers);
console.log(CoreContainer.handlers);

there i see my managers loaded, but its not in the same Container.

I tried also to do this in my core project
Reflect.setMetadata('service', 'HELLO', Error);

And then i did this in my main project, it worked for me.

const metadataValue = Reflect.getMetadata('service', Error);
if (metadataValue) {
  console.log('Metadata exists:', metadataValue);
} else {
  console.log('Metadata does not exist');
}

So... i dont know what to do next.

Its telling me to
ServiceNotFoundError: Service with "LoggerManager" identifier was not found in the container. Register it before usage via explicitly calling the "Container.set" function or using the "@Service()" decorator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questionQuestions about the usage of the library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions