Skip to content

Commit 4a311c4

Browse files
fix: use require() to load JSON protos (#242)
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 3b1af89 commit 4a311c4

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

packages/google-cloud-webrisk/src/v1/web_risk_service_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
2222
import * as path from 'path';
2323

2424
import * as protos from '../../protos/protos';
25+
import jsonProtos = require('../../protos/protos.json');
2526
/**
2627
* Client JSON configuration object, loaded from
2728
* `src/v1/web_risk_service_client_config.json`.
@@ -137,22 +138,7 @@ export class WebRiskServiceClient {
137138
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
138139
}
139140
// Load the applicable protos.
140-
// For Node.js, pass the path to JSON proto file.
141-
// For browsers, pass the JSON content.
142-
143-
const nodejsProtoPath = path.join(
144-
__dirname,
145-
'..',
146-
'..',
147-
'protos',
148-
'protos.json'
149-
);
150-
this._protos = this._gaxGrpc.loadProto(
151-
opts.fallback
152-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
153-
require('../../protos/protos.json')
154-
: nodejsProtoPath
155-
);
141+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
156142

157143
// This API contains "path templates"; forward-slash-separated
158144
// identifiers to uniquely identify resources within the API.

packages/google-cloud-webrisk/src/v1beta1/web_risk_service_v1_beta1_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {Callback, CallOptions, Descriptors, ClientOptions} from 'google-gax';
2222
import * as path from 'path';
2323

2424
import * as protos from '../../protos/protos';
25+
import jsonProtos = require('../../protos/protos.json');
2526
/**
2627
* Client JSON configuration object, loaded from
2728
* `src/v1beta1/web_risk_service_v1_beta1_client_config.json`.
@@ -137,22 +138,7 @@ export class WebRiskServiceV1Beta1Client {
137138
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
138139
}
139140
// Load the applicable protos.
140-
// For Node.js, pass the path to JSON proto file.
141-
// For browsers, pass the JSON content.
142-
143-
const nodejsProtoPath = path.join(
144-
__dirname,
145-
'..',
146-
'..',
147-
'protos',
148-
'protos.json'
149-
);
150-
this._protos = this._gaxGrpc.loadProto(
151-
opts.fallback
152-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
153-
require('../../protos/protos.json')
154-
: nodejsProtoPath
155-
);
141+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
156142

157143
// Put together the default options sent with requests.
158144
this._defaults = this._gaxGrpc.constructSettings(

0 commit comments

Comments
 (0)