Created
March 13, 2023 05:07
-
-
Save frencojobs/c7fe5b6c66b4a7c348fe7b430bc436b4 to your computer and use it in GitHub Desktop.
Dropper Pattern in NestJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Module, Inject, Injectable, ConfigurableModuleBuilder} from '@nestjs/common' | |
const {ConfigurableModuleClass, MODULE_OPTIONS_TOKEN} = new ConfigurableModuleBuilder<unknown>().build() | |
@Injectable() | |
class DropperService<T> { | |
constructor(@Inject(MODULE_OPTIONS_TOKEN) private readonly value: T) {} | |
drop(): T { | |
return this.value | |
} | |
} | |
@Module({ | |
providers: [DropperService], | |
exports: [DropperService] | |
}) | |
export class DropperModule extends ConfigurableModuleClass {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment