UNPKG

eventstore-interconnect

Version:
90 lines 3.85 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var DriverModule_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.DriverModule = void 0; const common_1 = require("@nestjs/common"); const __1 = require(".."); const driver_1 = require("./driver"); const http_driver_service_1 = require("./services/http-driver/http-driver.service"); const grpc_driver_service_1 = require("./services/grpc-driver/grpc-driver.service"); const constants_1 = require("../constants"); const safety_net_1 = require("../safety-net"); const connections_guards_1 = require("../connections-guards"); const db_client_1 = require("@eventstore/db-client"); const connections_initializers_1 = require("../connections-initializers"); let DriverModule = DriverModule_1 = class DriverModule { static get(configuration, customSafetyNetStrategy) { const driverProviders = (0, __1.isLegacyConf)(configuration.destination) ? this.getLegacyEventStoreDriver(configuration) : this.getNextEventStoreDriver(configuration); return { module: DriverModule_1, imports: [safety_net_1.SafetyNetModule.use(customSafetyNetStrategy)], providers: [...driverProviders], exports: [...driverProviders, safety_net_1.SafetyNetModule], }; } static getNextEventStoreDriver(configuration) { return [ { provide: constants_1.CONNECTION_CONFIGURATION, useValue: configuration.destination, }, { provide: driver_1.DRIVER, useClass: grpc_driver_service_1.GrpcDriverService, }, { provide: constants_1.CREDENTIALS, useValue: configuration.destination.credentials, }, { provide: connections_initializers_1.GRPC_CONNECTION_INITIALIZER, useClass: __1.GrpcConnectionInitializerService, }, { provide: constants_1.EVENTSTORE_DB_CLIENT, useValue: db_client_1.EventStoreDBClient, }, { provide: __1.EVENTSTORE_CONNECTION_GUARD, useClass: __1.NextConnectionGuardService, }, ]; } static getLegacyEventStoreDriver(configuration) { return [ { provide: driver_1.DRIVER, useClass: http_driver_service_1.HttpDriverService, }, { provide: constants_1.CREDENTIALS, useValue: configuration.destination.credentials, }, { provide: constants_1.CONNECTION_CONFIGURATION, useValue: configuration.destination, }, { provide: __1.TCP_EVENTSTORE_CLIENT_CONNECTION_INITIALIZER, useClass: __1.TCPEventStoreConnectionInitializerService, }, { provide: __1.EVENTSTORE_CONNECTION_GUARD, useClass: connections_guards_1.LegacyConnectionGuardService, }, ]; } }; DriverModule = DriverModule_1 = __decorate([ (0, common_1.Module)({}) ], DriverModule); exports.DriverModule = DriverModule; //# sourceMappingURL=driver.module.js.map