Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/oak_nest/mod.ts>FactoryProvider

Refer to nestjs to realize some common functions for Deno, support hono and oak
Latest
interface FactoryProvider
import { type FactoryProvider } from "https://deno.land/x/oak_nest@v3.0.1/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.