Registry / devops / nx-grpc-kit

nx-grpc-kit

JSON →
library0.4.0jsnpmunverified

Nx plugin for gRPC proto generation and composable gRPC-web interceptors for Angular. Provides 13 closure-based interceptor factories (auth, retry, deadline, circuit breaker, caching, offline queue, dev tools, toasts) with zero `@Injectable()` boilerplate. Includes an Nx executor for proto code generation using protoc and plugins auto-installed from npm. Current version 0.4.0. Key differentiators: framework-agnostic interceptors (Firebase, Auth0, Keycloak), no token revocation on failure, ESM-only, TypeScript types included.

npm install nx-grpc-kit
INSTALL
IMPORT
SIG · NX-GRPC-KIT
N
nx-grpc-kit
devopsjavascriptv0.4.0
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.

provideGrpcInterceptors
import { provideGrpcInterceptors } from 'nx-grpc-kit'
import { provideGrpcInterceptors } from 'nx-grpc-kit/interceptors'
The function is re-exported from the main entry point. Importing from 'nx-grpc-kit/interceptors' will not work.
withAuth
import { withAuth } from 'nx-grpc-kit'
const { withAuth } = require('nx-grpc-kit')
ESM-only. CommonJS require() will not work.
withRetry
import { withRetry } from 'nx-grpc-kit'
import { withRetry } from '@nx-grpc-kit/interceptors'
All interceptors are exported from the root package, not a subpath.

Configures Angular app providers with gRPC-web interceptors: Firebase auth, retry, deadline, dev tools, and error toasts.

import { provideGrpcInterceptors, withFirebaseAuth, withRetry, withDeadline, withDevTools, withToast } from 'nx-grpc-kit'; import { GrpcCoreModule, GrpcWebClientModule } from '@ngx-grpc/core'; import { importProvidersFrom } from '@angular/core'; import { environment } from '../environments/environment'; import { getAuth } from 'firebase/auth'; import { authStore } from './auth.store'; // assume defined import { toastService } from './toast.service'; // assume defined export const appConfig: ApplicationConfig = { providers: [ importProvidersFrom(GrpcCoreModule.forRoot()), importProvidersFrom( GrpcWebClientModule.forRoot({ settings: { host: environment.grpcURL } }), ), ...provideGrpcInterceptors( withFirebaseAuth({ getToken: () => getAuth().currentUser?.getIdToken() ?? Promise.resolve(null), getMetadata: () => ({ orgid: authStore.selectedOrgId(), propertyid: authStore.selectedPropId(), }), }), withRetry({ maxRetries: 3 }), withDeadline(15_000), withDevTools({ enabled: !environment.production }), withToast({ handler: (err) => toastService.showError(err.message) }), ), ], };
Debug
Known issues
gotchaAll interceptors are closure-based factories, not classes. Do not use `@Injectable()` or `useClass` providers.
fix
Use `provideGrpcInterceptors()` with factory functions directly. No decorators needed.
affects: *
gotchaThe package is ESM-only. Using `require()` (CommonJS) will throw an error.
fix
Use `import` syntax. Ensure `"type": "module"` in package.json or use `.mjs` extension.
affects: >=0.4.0
gotchaImport `provideGrpcInterceptors` from the root package (`nx-grpc-kit`), not from `nx-grpc-kit/interceptors`.
fix
`import { provideGrpcInterceptors } from 'nx-grpc-kit'`
affects: *
gotchaThe package does not export any individual interceptor from a subpath. All interceptors are exported from the root.
fix
Import interceptors like `withAuth`, `withRetry`, etc. from `nx-grpc-kit` directly.
affects: *
Errors
Common errors & fixes
Cannot find module 'nx-grpc-kit' or its corresponding type declarations.
Missing `@angular/core` or other peer deps. TypeScript may not resolve the package.
fix
Install peer dependencies: `npm install @angular/core @ngx-grpc/core @ngx-grpc/common rxjs`
Module not found: Error: Can't resolve 'nx-grpc-kit/interceptors'
Importing from subpath that does not exist.
fix
Change import to `nx-grpc-kit` (root package).
require() of ES Module nx-grpc-kit not supported.
Using CommonJS `require()` with an ESM-only package.
fix
Use `import` syntax or set `"type": "module"` in package.json.
Upgrade
Version history
0.4.0latest on npm
Audit
Dependencies
@angular/corerequiredPeer dependency: provides Angular injector and ApplicationConfig type.
@ngx-grpc/commonrequiredPeer dependency: gRPC-web common utilities.
@ngx-grpc/corerequiredPeer dependency: gRPC-web core module (GrpcCoreModule, GrpcWebClientModule).
rxjsrequiredPeer dependency: Observable-based gRPC client.
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
nx-grpc-kit — npm install nx-grpc-kit · libregistry