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

x/deno_nest/src/interfaces/provider.interface.ts>FactoryProvider

Refer to nestjs to realize some common functions for Deno, support hono and oak
Go to Latest
interface FactoryProvider
import { type FactoryProvider } from "https://deno.land/x/deno_nest@v3.5.2/src/interfaces/provider.interface.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<Provide | { token: Provide; optional: boolean; }>

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.