UNPKG

@sentzunhat/zacatl

Version:

A modular, high-performance TypeScript microservice framework for Node.js, featuring layered architecture, dependency injection, and robust validation for building scalable APIs and distributed systems.

38 lines 1.47 kB
import { resolveDependencies } from '../../../dependency-injection/index.js'; import { InternalServerError } from '../../../error/index.js'; import { getContainer } from '../../../dependency-injection/container.js'; export class Infrastructure { config; constructor(config) { this.config = config; this.register(); } register() { if (this.config.repositories && this.config.repositories.length > 0) { this.registerRepositories(); } } registerRepositories() { if (!this.config.repositories) { return; } for (const repository of this.config.repositories) { getContainer().registerSingleton(repository, repository); } const resolvedRepositories = resolveDependencies(this.config.repositories); if (resolvedRepositories.length !== this.config.repositories.length) { throw new InternalServerError({ message: 'Failed to register all infrastructure repository dependencies', reason: 'Not all repositories could be resolved from DI container', component: 'InfrastructureLayer', operation: 'register', metadata: { expected: this.config.repositories.length, resolved: resolvedRepositories.length, }, }); } } start() { } } //# sourceMappingURL=infrastructure.js.map