Skip to content

Commit

Permalink
fix(microservices): npm run format
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkummer committed Oct 27, 2021
1 parent 25dbb33 commit fdf11a5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
20 changes: 11 additions & 9 deletions packages/microservices/client/client-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ import { Logger } from '@nestjs/common/services/logger.service';
import { loadPackage } from '@nestjs/common/utils/load-package.util';
import { isFunction, isObject } from '@nestjs/common/utils/shared.utils';
import { Observable, Subscription } from 'rxjs';
import {
GRPC_DEFAULT_PROTO_LOADER,
GRPC_DEFAULT_URL,
} from '../constants';
import { GRPC_DEFAULT_PROTO_LOADER, GRPC_DEFAULT_URL } from '../constants';
import { InvalidGrpcPackageException } from '../errors/invalid-grpc-package.exception';
import { InvalidGrpcServiceException } from '../errors/invalid-grpc-service.exception';
import { InvalidProtoDefinitionException } from '../errors/invalid-proto-definition.exception';
import { ClientGrpc, GrpcOptions } from '../interfaces';
import { ClientProxy } from './client-proxy';
import { GRPC_CANCELLED } from './constants';
import {ChannelOptions} from "../external/grpc-options.interface";
import { ChannelOptions } from '../external/grpc-options.interface';

let grpcPackage: any = {};
let grpcProtoLoaderPackage: any = {};
Expand Down Expand Up @@ -64,15 +61,20 @@ export class ClientGrpcProxy extends ClientProxy implements ClientGrpc {
throw new InvalidGrpcServiceException();
}

const channelOptions: ChannelOptions = this.options && this.options.channelOptions ? this.options.channelOptions : {};
const channelOptions: ChannelOptions =
this.options && this.options.channelOptions
? this.options.channelOptions
: {};
if (this.options && this.options.maxSendMessageLength) {
channelOptions["grpc.max_send_message_length"] = this.options.maxSendMessageLength;
channelOptions['grpc.max_send_message_length'] =
this.options.maxSendMessageLength;
}
if (this.options && this.options.maxReceiveMessageLength) {
channelOptions["grpc.max_receive_message_length"] = this.options.maxReceiveMessageLength;
channelOptions['grpc.max_receive_message_length'] =
this.options.maxReceiveMessageLength;
}
if (this.options && this.options.maxMetadataSize) {
channelOptions["grpc.max_metadata_size"] = this.options.maxMetadataSize;
channelOptions['grpc.max_metadata_size'] = this.options.maxMetadataSize;
}

const keepaliveOptions = this.getKeepaliveOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export interface CustomStrategy {
export interface GrpcOptions {
transport?: Transport.GRPC;
options: {
interceptors?: Array<(options: any, nextCall: (options: any) => any) => any>;
interceptors?: Array<
(options: any, nextCall: (options: any) => any) => any
>;
url?: string;
maxSendMessageLength?: number;
maxReceiveMessageLength?: number;
Expand Down
15 changes: 10 additions & 5 deletions packages/microservices/server/server-grpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { InvalidProtoDefinitionException } from '../errors/invalid-proto-definit
import { CustomTransportStrategy, MessageHandler } from '../interfaces';
import { GrpcOptions } from '../interfaces/microservice-configuration.interface';
import { Server } from './server';
import {ChannelOptions} from "../external/grpc-options.interface";
import { ChannelOptions } from '../external/grpc-options.interface';

let grpcPackage: any = {};
let grpcProtoLoaderPackage: any = {};
Expand Down Expand Up @@ -332,15 +332,20 @@ export class ServerGrpc extends Server implements CustomTransportStrategy {
}

public async createClient(): Promise<any> {
const channelOptions: ChannelOptions = this.options && this.options.channelOptions ? this.options.channelOptions : {};
const channelOptions: ChannelOptions =
this.options && this.options.channelOptions
? this.options.channelOptions
: {};
if (this.options && this.options.maxSendMessageLength) {
channelOptions["grpc.max_send_message_length"] = this.options.maxSendMessageLength;
channelOptions['grpc.max_send_message_length'] =
this.options.maxSendMessageLength;
}
if (this.options && this.options.maxReceiveMessageLength) {
channelOptions["grpc.max_receive_message_length"] = this.options.maxReceiveMessageLength;
channelOptions['grpc.max_receive_message_length'] =
this.options.maxReceiveMessageLength;
}
if (this.options && this.options.maxMetadataSize) {
channelOptions["grpc.max_metadata_size"] = this.options.maxMetadataSize;
channelOptions['grpc.max_metadata_size'] = this.options.maxMetadataSize;
}
const server = new grpcPackage.Server(channelOptions);
const credentials = this.getOptionsProp(this.options, 'credentials');
Expand Down

0 comments on commit fdf11a5

Please sign in to comment.