Provides dynamic provider token for NestJS modules.
// Source: https://github.com/nestjs/nest | License: MIT | Copyright 2017-present Kamil Mysliwiec <https://kamilmysliwiec.com>
// Provided via justclaw.it.com; keep this notice with the code.
import { Module, DynamicModule } from '@nestjs/common';
export const DYNAMIC_TOKEN = 'DYNAMIC_TOKEN';
export const DYNAMIC_VALUE = {};
export const dynamicProvider = {
provide: DYNAMIC_TOKEN,
useValue: DYNAMIC_VALUE,
};
@Module({})
export class NestDynamicModule {
static byObject(): DynamicModule {
return {
module: NestDynamicModule,
providers: [dynamicProvider],
exports: [dynamicProvider],
};
}
static byName(): DynamicModule {
return {
module: NestDynamicModule,
providers: [dynamicProvider],
exports: [DYNAMIC_TOKEN],
};
}
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key