UNPKG

@creditkarma/thrift-client

Version:

Thrift client library for NodeJS written in TypeScript.

50 lines 2.4 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.createHttpClient = exports.createTcpClient = exports.createClient = void 0; const thrift_server_core_1 = require("@creditkarma/thrift-server-core"); const HttpConnection_1 = require("./HttpConnection"); const NullConnection_1 = require("./NullConnection"); const TcpConnection_1 = require("./TcpConnection"); __exportStar(require("./HttpConnection"), exports); __exportStar(require("./TcpConnection"), exports); function createClient(ServiceClient, options) { console.warn(`[Deprecated]: Please use 'createHttpClient' instead`); return createHttpClient(ServiceClient, options); } exports.createClient = createClient; function createTcpClient(ServiceClient, options) { const connection = new TcpConnection_1.TcpConnection(options); connection.register(...(options.register || [])); return new ServiceClient(connection); } exports.createTcpClient = createTcpClient; function createHttpClient(ServiceClient, options) { let serviceName = ''; if (ServiceClient.serviceName !== 'undefined') { serviceName = ServiceClient.serviceName; } else { const nullConnection = new NullConnection_1.NullConnection(thrift_server_core_1.BufferedTransport, thrift_server_core_1.BinaryProtocol); const nullClient = new ServiceClient(nullConnection); serviceName = nullClient._serviceName; } const connection = new HttpConnection_1.HttpConnection((0, thrift_server_core_1.deepMerge)(options, { serviceName })); connection.register(...(options.register || [])); return new ServiceClient(connection); } exports.createHttpClient = createHttpClient; //# sourceMappingURL=index.js.map