npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@coolsiarh/contracts

v1.0.1

Published

Contracts for microservices

Readme

Protocol Buffers (protobuf) - TypeScript Code Generation

This directory contains Protocol Buffer definitions for the TeaCinema backend services.

Overview

Protocol Buffers (protobuf) is a method of serializing structured data developed by Google. It's useful for defining APIs and services that communicate over the network.

Prerequisites

Before you can generate TypeScript types from .proto files, ensure you have the following installed:

  • protoc (Protocol Buffer Compiler) - Installation Guide
  • protoc-gen-ts or protoc-gen-ts_pb (TypeScript code generator)

Installation Steps

Windows

  1. Install protoc using Chocolatey (recommended):

    choco install protoc
  2. Or download and install manually:

  3. Install TypeScript protoc plugin:

    npm install --save-dev @protocolbuffers/protobuf
    npm install --save-dev ts-proto

macOS/Linux

# Using Homebrew (macOS)
brew install protobuf

# Using apt (Ubuntu/Debian)
sudo apt-get install protobuf-compiler

# Install TypeScript protoc plugin
npm install --save-dev ts-proto

Project Structure

contracts/
├── proto/
│   ├── auth.proto
│   └── ... (other .proto files)
├── gen/
│   └── ... (auto-generated TypeScript files)
├── package.json
└── README.md

Available Services

AuthService (auth.proto)

Service for authentication-related operations.

SendOtp

Sends an OTP (One-Time Password) to the specified identifier.

Request:

message SendOtpRequest {
  string identifier = 1;  // Email or phone number
  string type = 2;        // OTP type (e.g., "email", "sms")
}

Response:

message SendOtpResponse {
  bool ok = 1;  // Whether the OTP was sent successfully
}

Generating TypeScript Types

Using ts-proto with NestJS Support

This project uses ts-proto to generate TypeScript types with NestJS integration. The generated code is compatible with NestJS microservices.

Quick Start Command

Generate TypeScript types from all .proto files:

npm run generate

Or manually with protoc:

protoc -I ./proto ./proto/*.proto --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit

Command Breakdown

  • -I ./proto - Sets the proto files directory as import path
  • ./proto/*.proto - Generates from all proto files in the proto directory
  • --plugin=protoc-gen-ts_proto - Specifies the ts-proto plugin path
  • --ts_proto_out=./gen - Output directory for generated files
  • --ts_proto_opt=nestJs=true - Generates NestJS-compatible service interfaces
  • --ts_proto_opt=package=omit - Omits package prefix from generated types

Alternative: Using NPM Script

For convenience, use the npm script defined in package.json:

npm run proto:generate

NPM Scripts

Add these scripts to your package.json for easy code generation:

{
  "scripts": {
    "proto:generate": "protoc -I ./proto ./proto/*.proto --plugin=protoc-gen-ts_proto=\"$(pwd)/node_modules/.bin/protoc-gen-ts_proto.cmd\" --ts_proto_out=./gen --ts_proto_opt=nestJs=true,package=omit",
    "proto:clean": "rm -rf gen/*.ts",
    "proto:build": "npm run proto:clean && npm run proto:generate"
  }
}

Then run:

npm run proto:build

Using Generated TypeScript Types

After generation, import and use the types in your TypeScript code:

import { LoginRequest, LoginResponse } from "./generated/proto/auth";

const loginRequest: LoginRequest = {
  email: "[email protected]",
  password: "password123",
};

// Use with gRPC services or REST APIs

Output Options

Common protoc Flags

  • --ts_proto_out - Output directory for generated files
  • --plugin - Path to the TypeScript code generator plugin
  • --proto_path (or -I) - Search path for imported proto files

Example with custom output:

protoc \
  -I=proto \
  --plugin=./node_modules/.bin/protoc-gen-ts_proto \
  --ts_proto_out=./src/generated/proto \
  proto/auth.proto

Workflow Example

  1. Define your messages in proto/auth.proto
  2. Run generation:
    npm run proto:build
  3. Generated files appear in generated/ directory
  4. Import and use types in your application

Troubleshooting

"protoc: command not found"

Ensure protoc is installed and added to your PATH:

protoc --version

Plugin not found

Make sure the plugin path is correct and node_modules is installed:

npm install

Permission errors

On macOS/Linux, you may need to make the plugin executable:

chmod +x ./node_modules/.bin/protoc-gen-ts_proto

Resources

License

This project uses Protocol Buffers, which is covered under the 3-Clause BSD License.