@molecule-dev/ticketapp-contracts
v1.0.5
Published
Protocol Buffer definitions and generated TypeScript code
Readme
Contracts
Protocol Buffer definitions and generated TypeScript code .
Directory Structure
proto/- Protocol Buffer definition files (.proto)gen/- Generated TypeScript files
Generating TypeScript from Proto Files
To generate TypeScript files from the proto definitions, run:
protoc \
--proto_path=./proto \
--ts_proto_out=./gen \
--ts_proto_opt=nestJs=true,package=omit \
./proto/*.protoPrerequisites
Make sure you have ts-proto installed globally:
npm install -g ts-protoOptions
--proto_path=./proto- Specifies the directory containing proto files--ts_proto_out=./gen- Output directory for generated TypeScript files--ts_proto_opt- ts-proto options:nestJs=true- Generate NestJS-compatible code with decoratorsaddGrpcMetadata=true- Add gRPC metadata parameter to methodsaddNestjsRestParameter=true- Add rest parameter for additional argumentsoutputServices=grpc-js- Generate service definitions for @grpc/grpc-jsuseExactTypes=false- Use simpler type definitions
./proto/*.proto- Input proto files
Using in NestJS
The generated code includes:
AuthServiceController- Interface for your controller implementationAuthServiceControllerMethods()- Decorator to apply to your controller classAuthServiceClient- Interface for client-side usageAuthServiceService- gRPC service definition for module configuration
