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.
AppModule
✓ import { AppModule } from 'cache-grpc-server'
✗ const AppModule = require('cache-grpc-server').AppModule
ESM-only; named export. AppModule.register() used for custom storage.
SetRequestInterface
✓ import { SetRequestInterface } from 'cache-grpc-server'
Named export for custom storage implementation.
StorageStrategyInterface
✓ import { StorageStrategyInterface } from 'cache-grpc-server'
✗ import { StorageStrategy } from 'cache-grpc-server'
Interface not class; name differs from common expectation.
GrpcClientOptions
✓ import { GrpcClientOptions } from 'cache-grpc-server'
Used to obtain gRPC client options for microservice connection.
Minimal NestJS bootstrap with custom storage strategy replacing Redis backend.
// Use as a library: custom storage example
import { NestFactory } from '@nestjs/core';
import { AppModule, SetRequestInterface, StorageStrategyInterface, GrpcClientOptions } from 'cache-grpc-server';
import { MicroserviceOptions } from '@nestjs/microservices';
import { Injectable } from '@nestjs/common';
@Injectable()
class CustomStorageStrategy implements StorageStrategyInterface {
async existsMulti(keys: string[]): Promise<boolean[]> {
return keys.map(() => true);
}
async getMulti(keys: string[]): Promise<string[]> {
return keys.map(k => `value_${k}`);
}
async save(data: SetRequestInterface): Promise<string> {
return data.key;
}
}
async function bootstrap() {
const app = await NestFactory.create(AppModule.register(CustomStorageStrategy));
const grpcClientOptions = app.get(GrpcClientOptions);
app.connectMicroservice<MicroserviceOptions>(grpcClientOptions.getOptions());
await app.startAllMicroservices();
await app.init();
return app;
}
bootstrap().then(() => console.log('Server started')).catch(err => console.error(err));
Errors
Common errors & fixes
Error: Cannot find module 'cache-grpc-server'
Package not installed or wrong import path
fixRun 'npm install cache-grpc-server' and ensure import is correct: 'import { ... } from 'cache-grpc-server' TypeError: AppModule.register is not a function
Using default import instead of named import or incorrect version
fixUse named import: import { AppModule } from 'cache-grpc-server' error: [tls] option.secureContext is an invalid argument
Misconfigured TLS environment variables without valid key/cert files
fixSet TLS_INSECURE=true for development or provide correct paths to TLS files.
Audit
Dependencies
@grpc/grpc-jsrequiredgRPC core client/server library used for streaming RPCs and reflection
ioredisrequiredRedis client used as the default storage backend
@nestjs/coreoptionalNestJS framework dependency for modularity and microservice support