Skip to content

Commit cb29de0

Browse files
committed
Added back port usage
1 parent 5db3e15 commit cb29de0

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

common/api-review/data-connect.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ export interface TransportOptions {
259259
// (undocumented)
260260
host: string;
261261
// (undocumented)
262+
port?: number;
263+
// (undocumented)
262264
sslEnabled?: boolean;
263265
}
264266

packages/data-connect/src/api/DataConnect.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface ConnectorConfig {
5757
*/
5858
export interface TransportOptions {
5959
host: string;
60+
port?: number;
6061
sslEnabled?: boolean;
6162
}
6263

@@ -185,6 +186,7 @@ export class DataConnect {
185186
if (this._transportOptions) {
186187
this._transport.useEmulator(
187188
this._transportOptions.host,
189+
this._transportOptions.port,
188190
this._transportOptions.sslEnabled
189191
);
190192
}

packages/data-connect/src/network/transport/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export interface DataConnectTransport {
5151
queryName: string,
5252
body?: U
5353
): Promise<{ data: T; errors: Error[] }>;
54-
useEmulator(host: string, sslEnabled?: boolean): void;
54+
useEmulator(host: string, port: number, sslEnabled?: boolean): void;
5555
onTokenChanged: (token: string | null) => void;
5656
_setCallerSdkType(callerSdkType: CallerSdkType): void;
5757
}

packages/data-connect/src/network/transport/rest.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { CallerSdkType, CallerSdkTypeEnum, DataConnectTransport } from '.';
2727

2828
export class RESTTransport implements DataConnectTransport {
2929
private _host = '';
30+
private _port: number | undefined;
3031
private _location = 'l';
3132
private _connectorName = '';
3233
private _secure = true;
@@ -46,6 +47,9 @@ export class RESTTransport implements DataConnectTransport {
4647
private _callerSdkType: CallerSdkType = CallerSdkTypeEnum.Base
4748
) {
4849
if (transportOptions) {
50+
if (typeof transportOptions.port === 'number') {
51+
this._port = transportOptions.port;
52+
}
4953
if (typeof transportOptions.sslEnabled !== 'undefined') {
5054
this._secure = transportOptions.sslEnabled;
5155
}
@@ -84,11 +88,14 @@ export class RESTTransport implements DataConnectTransport {
8488
projectId: this._project,
8589
service: this._serviceName
8690
},
87-
{ host: this._host, sslEnabled: this._secure }
91+
{ host: this._host, sslEnabled: this._secure, port: this._port }
8892
);
8993
}
90-
useEmulator(host: string, isSecure?: boolean): void {
94+
useEmulator(host: string, port?: number, isSecure?: boolean): void {
9195
this._host = host;
96+
if (typeof port === 'number') {
97+
this._port = port;
98+
}
9299
if (typeof isSecure !== 'undefined') {
93100
this._secure = isSecure;
94101
}

packages/data-connect/test/unit/dataconnect.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,3 @@ describe('Data Connect Test', () => {
8282
expect(parsedHost.sslEnabled).to.be.false;
8383
});
8484
});
85-

0 commit comments

Comments
 (0)