Skip to main content
Module

x/oak_nest/mod.ts>FactoryProvider

Refer to nestjs to realize some common functions for Deno
Go to Latest
interface FactoryProvider
import { type FactoryProvider } from "https://deno.land/x/oak_nest@v1.15.2/mod.ts";

Interface defining a Factory type provider.

For example:

const connectionFactory = {
  provide: 'CONNECTION',
  useFactory: (optionsProvider: OptionsProvider) => {
    const options = optionsProvider.get();
    return new DatabaseConnection(options);
  },
  inject: [OptionsProvider],
};

Type Parameters

optional
T = any

Properties

provide: Provide

Injection token

useFactory: (...args: any[]) => T

Factory function that returns an instance of the provider to be injected.

optional
inject: Array<
| Type<any>
| string
| symbol
| Abstract<any>
| Function
>

Optional list of providers to be injected into the context of the Factory function.

optional
scope: Scope

Optional enum defining lifetime of the provider that is returned by the Factory function.