UNPKG

nestjs-express-cassandra

Version:
30 lines (29 loc) 1.44 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createNewConnection = void 0; const common_1 = require("@nestjs/common"); const rxjs_1 = require("rxjs"); const connection_1 = require("../connection"); const express_cassandra_core_module_1 = require("../express-cassandra-core.module"); const providers_1 = require("./providers"); function createNewConnection(options) { const cassandraOptions = __rest(options, []); const connection = new connection_1.default(cassandraOptions); connection.name = (0, providers_1.getConnectionProviderName)(options); return (0, rxjs_1.lastValueFrom)((0, rxjs_1.defer)(() => connection.initAsync()).pipe((0, rxjs_1.map)(() => { common_1.Logger.debug(`[${connection.name}] connection initialized`, express_cassandra_core_module_1.ExpressCassandraCoreModule.name); return connection; }))); } exports.createNewConnection = createNewConnection;