Registry / devops / grpc-web-service-generator

grpc-web-service-generator

JSON →
library0.2.3jsnpmunverified

A CLI tool and runtime wrapper for generating and using gRPC-Web client services from proto files. Current version 0.2.3, updated occasionally. Key differentiator: simplifies gRPC-Web setup by generating a GrpcService class with interceptor and access token support, handling proto package names across versions. Compared to raw grpc-web, it reduces boilerplate for common patterns like auth tokens and error retries.

npm install grpc-web-service-generator
INSTALL
IMPORT
SIG · GRPC-WEB-SERVICE-G
G
grpc-web-service-generator
devopsjavascriptv0.2.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GrpcService
import { GrpcService } from './GrpcService';
const GrpcService = require('./GrpcService');
Generated file, not from the npm package. ESM-style import required for correct module resolution.
GrpcWebClientRpcOptions
import { GrpcWebClientRpcOptions } from 'grpc-web-service-generator';
Type/interface for RPC options when customizing calls.

Shows generating service code from proto and using GrpcService with token, call, and error interceptor.

// 1. Generate service code // yarn grpc-web-service-generator --proto-file=./proto/rpc.proto --output-dir=./services/GrpcService // 2. Use generated service in client import { GrpcService } from './services/GrpcService'; const grpcService = new GrpcService('http://localhost:8080'); // Set auth token (optional) grpcService.setAccessToken('my-token'); // Call RPC (syntax depends on version) // Version >= 0.1.7: package name prefix // Version <= 0.1.6: direct service name grpcService.RpcPackage.TodoService.AddTodo({}).then(response => { console.log(response); }).catch(error => { console.error(error); }); // Add error interceptor grpcService.interceptors.errors.push((e) => { if (e === 'INVALID_TOKEN') { // Refresh token and retry return updateAccessToken(); } return Promise.resolve(); });
Debug
Known issues
breakingVersion <= 0.1.6: GrpcService services accessible directly without package name. Version >= 0.1.7: Package name required (e.g., grpcService.RpcPackage.TodoService).
fix
Access services via grpcService.<PackageName>.<ServiceName> after upgrading.
affects: <0.1.7
gotchaGenerated GrpcService file is output to the specified --output-dir; the import path must match that directory structure.
fix
Ensure import path matches --output-dir value (e.g., import from './services/GrpcService').
affects: all
gotchagrpc-web v1.x uses CommonJS, with grpc-web-service-generator not fully compatible with ESM bundlers like webpack 5; may require configuration.
fix
Use webpack 4 or configure module rules for CommonJS packages.
affects: all
Errors
Common errors & fixes
Cannot find module './GrpcService'
Import path does not match the generated output directory.
fix
Confirm --output-dir and adjust import to match (e.g., import { GrpcService } from './services/GrpcService').
grpcService.RpcPackage is undefined
Version mismatch: using version >= 0.1.7 but expecting direct service access.
fix
Add package name prefix: grpcService.RpcPackage.TodoService.AddTodo(...).
Upgrade
Version history
0.2.3latest on npm
Audit
Dependencies
grpc-webrequiredCore gRPC-Web runtime for making RPC calls
google-protobufrequiredProtobuf message serialization/deserialization
Agent activity
8 hits · last 30 days
node
8
Resources
grpc-web-service-generator — npm install grpc-web-service-generator · libregistry