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.

42 lines 1.66 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Infrastructure = void 0; const dependency_injection_1 = require("../../../dependency-injection/index.js"); const error_1 = require("../../../error/index.js"); const container_1 = require("../../../dependency-injection/container"); 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) { (0, container_1.getContainer)().registerSingleton(repository, repository); } const resolvedRepositories = (0, dependency_injection_1.resolveDependencies)(this.config.repositories); if (resolvedRepositories.length !== this.config.repositories.length) { throw new error_1.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() { } } exports.Infrastructure = Infrastructure; //# sourceMappingURL=infrastructure.js.map