@nestjs/common#FactoryProvider TypeScript Examples
The following examples show how to use
@nestjs/common#FactoryProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: bull.providers.spec.ts From nestjs-bullmq with MIT License | 6 votes |
describe('Providers', () => {
describe('createQueueProviders', () => {
it("should use top-level queue name if it's not specified in factory options", async () => {
const moduleOptions: BullModuleOptions = { name: 'top-level-queue-name' };
const factoryModuleOptions: BullModuleOptions = {
connection: { port: 6380 },
};
const provider = bullProviders.createQueueProviders([
moduleOptions,
])[0] as FactoryProvider;
let queue = provider.useFactory(factoryModuleOptions);
expect(queue.name).toEqual(moduleOptions.name);
await queue.close();
factoryModuleOptions.name = 'low-level-queue-name';
queue = provider.useFactory(factoryModuleOptions);
expect(queue.name).toEqual(factoryModuleOptions.name);
await queue.close();
});
});
});
Example #2
Source File: pact-publisher.provider.ts From nestjs-pact with MIT License | 5 votes |
PactPublisherProvider: FactoryProvider<Publisher> = {
provide: PactModuleProviders.PactPublisher,
useFactory: (options: PactPublicationOptions) => new Publisher(options),
inject: [PactModuleProviders.PublicationOptions],
}