Skip to content

Commit 50cbe77

Browse files
fix: use require() to load JSON protos (#42)
The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Link: googleapis/googleapis@75880c3 Source-Link: googleapis/googleapis-gen@77b1804
1 parent 1612b1e commit 50cbe77

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

packages/google-cloud-networkconnectivity/src/v1alpha1/hub_service_client.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import * as path from 'path';
3232
import {Transform} from 'stream';
3333
import {RequestType} from 'google-gax/build/src/apitypes';
3434
import * as protos from '../../protos/protos';
35+
import jsonProtos = require('../../protos/protos.json');
3536
/**
3637
* Client JSON configuration object, loaded from
3738
* `src/v1alpha1/hub_service_client_config.json`.
@@ -150,22 +151,7 @@ export class HubServiceClient {
150151
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
151152
}
152153
// Load the applicable protos.
153-
// For Node.js, pass the path to JSON proto file.
154-
// For browsers, pass the JSON content.
155-
156-
const nodejsProtoPath = path.join(
157-
__dirname,
158-
'..',
159-
'..',
160-
'protos',
161-
'protos.json'
162-
);
163-
this._protos = this._gaxGrpc.loadProto(
164-
opts.fallback
165-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
166-
require('../../protos/protos.json')
167-
: nodejsProtoPath
168-
);
154+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
169155

170156
// This API contains "path templates"; forward-slash-separated
171157
// identifiers to uniquely identify resources within the API.
@@ -207,15 +193,11 @@ export class HubServiceClient {
207193
),
208194
};
209195

196+
const protoFilesRoot = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
197+
210198
// This API contains "long-running operations", which return a
211199
// an Operation object that allows for tracking of the operation,
212200
// rather than holding a request open.
213-
const protoFilesRoot = opts.fallback
214-
? this._gaxModule.protobuf.Root.fromJSON(
215-
// eslint-disable-next-line @typescript-eslint/no-var-requires
216-
require('../../protos/protos.json')
217-
)
218-
: this._gaxModule.protobuf.loadSync(nodejsProtoPath);
219201

220202
this.operationsClient = this._gaxModule
221203
.lro({

0 commit comments

Comments
 (0)