Skip to content

Commit fdbc0fe

Browse files
fix: use require() to load JSON protos (googleapis#273)
The library is regenerated with gapic-generator-typescript v1.3.1. Committer: @alexander-fenster PiperOrigin-RevId: 372468161 Source-Link: googleapis/googleapis@75880c3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/77b18044813d4c8c415ff9ea68e76e307eb8e904
1 parent 073beac commit fdbc0fe

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

src/v1/recaptcha_enterprise_service_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import * as path from 'path';
3131
import {Transform} from 'stream';
3232
import {RequestType} from 'google-gax/build/src/apitypes';
3333
import * as protos from '../../protos/protos';
34+
import jsonProtos = require('../../protos/protos.json');
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1/recaptcha_enterprise_service_client_config.json`.
@@ -146,22 +147,7 @@ export class RecaptchaEnterpriseServiceClient {
146147
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
147148
}
148149
// Load the applicable protos.
149-
// For Node.js, pass the path to JSON proto file.
150-
// For browsers, pass the JSON content.
151-
152-
const nodejsProtoPath = path.join(
153-
__dirname,
154-
'..',
155-
'..',
156-
'protos',
157-
'protos.json'
158-
);
159-
this._protos = this._gaxGrpc.loadProto(
160-
opts.fallback
161-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
162-
require('../../protos/protos.json')
163-
: nodejsProtoPath
164-
);
150+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
165151

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

src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import * as path from 'path';
3131
import {Transform} from 'stream';
3232
import {RequestType} from 'google-gax/build/src/apitypes';
3333
import * as protos from '../../protos/protos';
34+
import jsonProtos = require('../../protos/protos.json');
3435
/**
3536
* Client JSON configuration object, loaded from
3637
* `src/v1beta1/recaptcha_enterprise_service_v1_beta1_client_config.json`.
@@ -146,22 +147,7 @@ export class RecaptchaEnterpriseServiceV1Beta1Client {
146147
clientHeader.push(`${opts.libName}/${opts.libVersion}`);
147148
}
148149
// Load the applicable protos.
149-
// For Node.js, pass the path to JSON proto file.
150-
// For browsers, pass the JSON content.
151-
152-
const nodejsProtoPath = path.join(
153-
__dirname,
154-
'..',
155-
'..',
156-
'protos',
157-
'protos.json'
158-
);
159-
this._protos = this._gaxGrpc.loadProto(
160-
opts.fallback
161-
? // eslint-disable-next-line @typescript-eslint/no-var-requires
162-
require('../../protos/protos.json')
163-
: nodejsProtoPath
164-
);
150+
this._protos = this._gaxGrpc.loadProtoJSON(jsonProtos);
165151

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

0 commit comments

Comments
 (0)