joetjen.net
EN DE
← All libraries
JavaScript

node-cooper-nestjs

A NestJS module that loads an application’s CASC configuration once, at startup, and feeds it to @nestjs/config’s ConfigService, each top-level block injectable on its own.

Intention

ConfigService stays the way you read configuration, and so does every third-party module configured through it. What CASC replaces is where the values come from — .env loading and configuration factories — not the API the rest of the application already uses.

Example
@Module({
  imports: [CooperConfigModule.forRoot()],   // loads config/config.casc, once; global
})
export class AppModule {}

@Injectable()
export class Mailer {
  constructor(
    private readonly config: ConfigService,                    // @nestjs/config, as always
    @InjectCooper('mail') private readonly mail: MailConfig,  // one block
  ) {}
}
Install
npm install @joetjen/cooper-nestjs @nestjs/config
NestJSConfiguration