-
-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rabbitmq): adds consistent rabbitmq config
use community convention of forRoot and forRootAsync to bootstrap module fix #34
- Loading branch information
1 parent
9bba7cb
commit 0923f62
Showing
5 changed files
with
104 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './mixins'; | ||
export * from './options'; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Type } from '@nestjs/common'; | ||
import { ModuleMetadata, Provider } from '@nestjs/common/interfaces'; | ||
|
||
export interface OptionsFactory<T> { | ||
createOptions(): Promise<T> | T; | ||
} | ||
|
||
export interface AsyncOptionsFactoryProvider<T> | ||
extends Pick<ModuleMetadata, 'imports'> { | ||
useExisting?: Type<OptionsFactory<T>>; | ||
useClass?: Type<OptionsFactory<T>>; | ||
useFactory?: (...args: any[]) => Promise<T> | T; | ||
inject?: any[]; | ||
} | ||
|
||
export function createAsyncOptionsProvider<T>( | ||
provide: string | symbol | Type<any>, | ||
options: AsyncOptionsFactoryProvider<T> | ||
): Provider { | ||
if (options.useFactory) { | ||
return { | ||
provide, | ||
useFactory: options.useFactory, | ||
inject: options.inject || [] | ||
}; | ||
} | ||
return { | ||
provide, | ||
useFactory: async (optionsFactory: OptionsFactory<T>) => | ||
await optionsFactory.createOptions(), | ||
inject: [options.useExisting || options.useClass] | ||
}; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export const RABBIT_HANDLER = Symbol('RABBIT_HANDLER'); | ||
export const RABBIT_CONFIG = Symbol('RABBIT_CONFIG'); |
This file contains 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
This file contains 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