REST GCP API
NestJS module for injecting GCP Project ID into applications.
What It Does
The REST GCP API provides a NestJS module that simplifies GCP Project ID injection into applications. It wraps the @engineering11/gcp package’s project discovery logic and exposes it through NestJS dependency injection.
Key Capabilities
- Automatic Project Discovery: Multi-source project ID resolution
- Dependency Injection: Inject project ID via NestJS DI
- Flexible Configuration: Sync, async, and custom client support
- Global Module Support: Available throughout entire application
- Type-Safe Injection: Symbol-based injection token
Main Component
GCPModule
@Module({
imports: [GCPModule]
})
export class AppModule {}Injection Pattern
@Injectable()
export class MyService {
constructor(
@Inject(GCP_PROJECT_ID) private projectId: string
) {}
}Registration Patterns
Default
GCPModuleWith Custom Client
GCPModule.register({client: customClient})Async
GCPModule.registerAsync({
imports: [ClientModule],
inject: [CustomClient],
useFactory: (client) => ({client})
})Global
GCPModule.register({isGlobal: true})Injection Token
export const GCP_PROJECT_ID = Symbol('GCP_PROJECT_ID')Common Use Cases
- GCP service initialization requiring project ID
- Multi-environment deployments
- Resource naming with project context
- Logging and monitoring tags
- Service configuration
What Customers Don’t Have to Build
- GCP project ID discovery
- NestJS module configuration
- Dependency injection setup
- Multi-source fallback logic
- Custom client integration
- Global module registration
Last updated on