Skip to content

Commit

Permalink
fix: deprecated grpc and replace with @grpc/grpc-js (#362)
Browse files Browse the repository at this point in the history
* fix depricated grpc and replace with @grpc/grpc-js

* Update codegen.

Co-authored-by: Stephen Haberman <stephen.haberman@gmail.com>
  • Loading branch information
iMitaka and stephenh authored Sep 17, 2021
1 parent f636655 commit 1a11b97
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion integration/nestjs-metadata-observables/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices';
import { util, configure } from 'protobufjs/minimal';
import * as Long from 'long';
import { Observable } from 'rxjs';
import { Metadata } from 'grpc';
import { Metadata } from '@grpc/grpc-js';

export const protobufPackage = 'hero';

Expand Down
2 changes: 1 addition & 1 deletion integration/nestjs-metadata-restparameters/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices';
import { util, configure } from 'protobufjs/minimal';
import * as Long from 'long';
import { Observable } from 'rxjs';
import { Metadata } from 'grpc';
import { Metadata } from '@grpc/grpc-js';

export const protobufPackage = 'hero';

Expand Down
2 changes: 1 addition & 1 deletion integration/nestjs-metadata/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GrpcMethod, GrpcStreamMethod } from '@nestjs/microservices';
import { util, configure } from 'protobufjs/minimal';
import * as Long from 'long';
import { Observable } from 'rxjs';
import { Metadata } from 'grpc';
import { Metadata } from '@grpc/grpc-js';

export const protobufPackage = 'hero';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
import { Metadata } from 'grpc';
import { Metadata } from '@grpc/grpc-js';

export const protobufPackage = 'basic';

Expand Down
4 changes: 2 additions & 2 deletions src/generate-nestjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function generateNestjsServiceController(
const { options } = ctx;
const chunks: Code[] = [];

const Metadata = options.outputServices === ServiceOption.GRPC ? imp('Metadata@@grpc/grpc-js') : imp('Metadata@grpc');
const Metadata = imp('Metadata@@grpc/grpc-js');

maybeAddComment(sourceInfo, chunks, serviceDesc.options?.deprecated);
const t = options.context ? `<${contextTypeVar}>` : '';
Expand Down Expand Up @@ -97,7 +97,7 @@ export function generateNestjsServiceClient(
const { options } = ctx;
const chunks: Code[] = [];

const Metadata = options.outputServices === ServiceOption.GRPC ? imp('Metadata@@grpc/grpc-js') : imp('Metadata@grpc');
const Metadata = imp('Metadata@@grpc/grpc-js');

maybeAddComment(sourceInfo, chunks);
const t = options.context ? `<${contextTypeVar}>` : ``;
Expand Down
2 changes: 1 addition & 1 deletion src/generate-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export function generateService(
// We have to use grpc.Metadata where grpc will come from @improbable-eng
params.push(code`metadata?: grpc.Metadata`);
} else if (options.addGrpcMetadata) {
const Metadata = imp('Metadata@grpc');
const Metadata = imp('Metadata@@grpc/grpc-js');
const q = options.addNestjsRestParameter ? '' : '?';
params.push(code`metadata${q}: ${Metadata}`);
}
Expand Down

0 comments on commit 1a11b97

Please sign in to comment.