1.0.0-alpha • Published 3 years ago

type-grpc v1.0.0-alpha

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
3 years ago

type-grpc

type-grpc is typescript library to generate grpc service definitions

installation

npm install type-grpc

OR

yarn add type-grpc

example

import {
  Service,
  RPC,
  Input,
  Message,
  Field,
  Metadata,
  RPCMeta,
} from 'type-grpc';

@Message()
class ServiceMethodResponse {
  @Field()
  uuid: string;

  @Field()
  message: string;
}

@Message()
export class MethodInput {
  @Field()
  name: string;
}

@Service()
export class ServiceName {
  @RPC(type => ServiceMethodResponse, {})
  async methodName(
            @Metadata() metadata: RPCMeta,
            @Input(type => MethodInput, { nullable: true }) input: MethodInput,
  ): Promise<ServiceMethodResponse> {
    return {
      uuid: 'f23fd-434dfs-4324fdsf-43432fd',
      message: `Hello ${input.name}`,
    };
  }
}

warning

this package is under development, so it's not production ready. any contributions in any way is appreciated