Add option to map the return values for the methods into Promises
Closed this issue · 1 comments
VictorGaiva commented
This makes possible to use the generate values to validade the controllers in NestJS, like this:
export namespace database {
export interface NetworkService {
getNetworkById(data: NetworkById, metadata?: Metadata): Promise<Network>;
}
export interface NetworkById {
id?: string;
}
export interface Network {
id?: number;
}
}
@Controller()
export class NetworkService implements database.NetworkService{
async getNetworkById({ id }: database.NetworkById, metadata?:Metadata) {
return await this.database.GetById(id);
}
}
AlexDaSoul commented
GrpcMethod by Nestjs always returns Rxjs Observable. But You can overraide compiller template use --template
param and copy template from https://github.com/AlexDaSoul/nestjs-proto-gen-ts/blob/master/templates/nestjs-grpc.hbs and change Observable to Promise.
$ tsproto --path ./hero-proto --template ./templates/new-nestjs-grpc.hbs