@simple-cinema/contracts
v1.2.4
Published
Protobuf definitions and generated TypeScript types
Readme
@simple-cinema/contracts
Shared Protobuf definitions and generated TypeScript types for Simple Cinema microservices.
Requirements
- protoc — Protocol Buffers compiler
- Node.js / npm or yarn
Installation
npm install @simple-cinema/contractsGenerate types
After editing .proto files, regenerate TypeScript types:
npm run generateOn Windows, the
generatescript requires the plugin path to be explicit:protoc -I ./proto ./proto/*.proto \ --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto.cmd \ --ts_proto_out=./gen \ --ts_proto_opt=nestJs=true,package=omit
Generated files are written to ./gen/.
Structure
contracts/
├── proto/ # .proto source files
│ └── auth.proto
└── gen/ # generated TypeScript files (do not edit manually)Services
AuthService (proto/auth.proto)
| RPC | Request | Response | |-----------|------------------|-------------------| | SendOtp | SendOtpRequest | SendOtpResponse |
SendOtpRequest | Field | Type | |------------|--------| | identifier | string | | type | string |
SendOtpResponse | Field | Type | |-------|------| | ok | bool |
Usage (NestJS)
import { AuthServiceClient } from '@simple-cinema/contracts/gen/auth';