You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* eslint-disable */import{GrpcMethod,GrpcStreamMethod}from"@nestjs/microservices";import{util,configure}from"protobufjs/minimal";import*asLongfrom"long";import{Observable}from"rxjs";import{Metadata}from"@grpc/grpc-js";exportconstprotobufPackage="proto.v1";/** demo.proto */exportinterfaceLoginRequest{name: string;password: string;}exportinterfaceLoginResponse{authCode: string;}exportconstPROTO_V1_PACKAGE_NAME="proto.v1";exportinterfaceTestServiceClient{login(request: LoginRequest,metadata?: Metadata): Observable<LoginResponse>;}exportinterfaceTestServiceController{login(request: LoginRequest,metadata?: Metadata): Promise<LoginResponse>|Observable<LoginResponse>|LoginResponse;}exportfunctionTestServiceControllerMethods(){returnfunction(constructor: Function){constgrpcMethods: string[]=["login"];for(constmethodofgrpcMethods){constdescriptor: any=Reflect.getOwnPropertyDescriptor(constructor.prototype,method);GrpcMethod("TestService",method)(constructor.prototype[method],method,descriptor);}constgrpcStreamMethods: string[]=[];for(constmethodofgrpcStreamMethods){constdescriptor: any=Reflect.getOwnPropertyDescriptor(constructor.prototype,method);GrpcStreamMethod("TestService",method)(constructor.prototype[method],method,descriptor);}};}exportconstTEST_SERVICE_NAME="TestService";// If you get a compile-error about 'Constructor<Long> and ... have no overlap',// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.if(util.Long!==Long){util.Long=Longasany;configure();}
In some NestJs project, only gRPC client is implemented and generated code with *Controller, *ControllerMethods related (TestServiceController, TestServiceControllerMethods above) are unwanted in this situation.
So a flag that can be set to only generate gPRC client related code would be nice.
After set the flag, the proto file above will produce code like:
/* eslint-disable */import{util,configure}from"protobufjs/minimal";import*asLongfrom"long";import{Observable}from"rxjs";import{Metadata}from"@grpc/grpc-js";exportconstprotobufPackage="proto.v1";/** demo.proto */exportinterfaceLoginRequest{name: string;password: string;}exportinterfaceLoginResponse{authCode: string;}exportconstPROTO_V1_PACKAGE_NAME="proto.v1";exportinterfaceTestServiceClient{login(request: LoginRequest,metadata?: Metadata): Observable<LoginResponse>;}exportconstTEST_SERVICE_NAME="TestService";// If you get a compile-error about 'Constructor<Long> and ... have no overlap',// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'.if(util.Long!==Long){util.Long=Longasany;configure();}
The text was updated successfully, but these errors were encountered:
I.e. turn the internal Options.nestJs into an array of options.nestJs: Array<'client' | 'server'> and then update optionsFromParameter to watch for nestJs=true and turn that into nestJs: ['client', 'server'].
If there is proto like this:
after
produce
In some NestJs project, only gRPC client is implemented and generated code with
*Controller
,*ControllerMethods
related (TestServiceController
,TestServiceControllerMethods
above) are unwanted in this situation.So a flag that can be set to only generate gPRC client related code would be nice.
After set the flag, the proto file above will produce code like:
The text was updated successfully, but these errors were encountered: