Registry / devops / grpc-ts-health-check

grpc-ts-health-check

JSON →
library3.1.3jsnpmunverified

Implementation of gRPC health checking protocol in TypeScript, version 3.1.3. Provides client and server health check services compatible with @grpc/grpc-js. Requires @grpc/grpc-js >=1.8.14 and @grpc/proto-loader >=0.7.7 as peer dependencies. Generates TypeScript types from .proto files. Key differentiator: full TypeScript support with type safety for health check requests and responses, enabling easy integration into gRPC microservices.

npm install grpc-ts-health-check
INSTALL
IMPORT
SIG · GRPC-TS-HEALTH-CHE
G
grpc-ts-health-check
devopsjavascriptv3.1.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.

HealthClient
import { HealthClient } from 'grpc-ts-health-check'
import HealthClient from 'grpc-ts-health-check'
Default export does not exist; use named import for HealthClient.
HealthServer
import { HealthServer } from 'grpc-ts-health-check'
Also available for implementing server-side health checks.
ServiceError
import { ServiceError } from '@grpc/grpc-js'
import { ServiceError } from 'grpc-ts-health-check'
ServiceError is part of @grpc/grpc-js, not grpc-ts-health-check.

Initializes a gRPC health check client, loads proto definition, and makes a check request.

import * as grpc from '@grpc/grpc-js'; import * as protoLoader from '@grpc/proto-loader'; import { HealthClient } from 'grpc-ts-health-check'; import { ProtoGrpcType } from './path/to/generated/health'; const packageDefinition = protoLoader.loadSync('./health.proto', { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true, }); const proto = grpc.loadPackageDefinition(packageDefinition) as unknown as ProtoGrpcType; const client = new HealthClient('localhost:50051', grpc.ChannelCredentials.createInsecure()); client.check({ service: 'myService' }, (error, response) => { if (error) { console.error(error); } else { console.log('Status:', response?.status); } });
Debug
Known issues
breakingVersion 3.0.0 dropped support for @grpc/grpc-js versions below 1.8.14. Upgrade peer dependency.
fix
Update @grpc/grpc-js to >=1.8.14 and @grpc/proto-loader to >=0.7.7.
affects: <3.0.0
deprecatedThe old HealthClient constructor with insecure credentials is deprecated. Use secure credentials in production.
fix
Pass grpc.ChannelCredentials.createSsl() or other secure credentials instead of createInsecure().
affects: >=3.0.0
gotchaImporting 'grpc-ts-health-check' without generating proto types fails. The package does not include pre-compiled .proto definitions.
fix
Generate TypeScript types from health.proto using protoc and the ts-proto plugin, then import generated types.
affects: >=2.0.0
gotchaThe 'watch' method returns a ClientReadableStream but the type may not be exported. You may need to manually cast.
fix
Use grpc.ClientReadableStream<HealthCheckResponse> from @grpc/grpc-js.
affects: >=3.0.0
deprecatedThe 'grpc-boom' dependency is deprecated and may cause security vulnerabilities. Consider migrating to @grpc/grpc-js error handling.
fix
Manually create ServiceError objects instead of using grpc-boom.
affects: >=2.0.0
Errors
Common errors & fixes
TypeError: grpc.loadPackageDefinition is not a function
Using an incompatible version of @grpc/grpc-js (likely <1.8.14).
fix
Upgrade @grpc/grpc-js to >=1.8.14 and @grpc/proto-loader to >=0.7.7.
Error: Cannot find module 'grpc-ts-health-check'
Package not installed or typo in import path.
fix
Run 'npm install grpc-ts-health-check' and ensure import path is correct.
Property 'check' does not exist on type 'HealthClient'
Missing proto type generation or incorrect type definition reference.
fix
Generate types from health.proto using ts-proto and import them, or cast to any.
Upgrade
Version history
3.1.3latest on npm
Audit
Dependencies
@grpc/grpc-jsrequiredPeer dependency: gRPC core library
@grpc/proto-loaderrequiredPeer dependency: loads gRPC proto files
google-protobufrequiredRuntime dependency: Protocol Buffers data format
grpc-boomrequiredRuntime dependency: creates gRPC-friendly errors
Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
grpc-ts-health-check — npm install grpc-ts-health-check · libregistry