UNPKG

@expressots/core

Version:

Expressots - modern, fast, lightweight nodejs web framework (@core)

62 lines (61 loc) 2.11 kB
"use strict"; /* eslint-disable @typescript-eslint/explicit-function-return-type */ /* eslint-disable @typescript-eslint/no-explicit-any */ Object.defineProperty(exports, "__esModule", { value: true }); exports.provideTransient = exports.provideSingleton = exports.provide = void 0; const binding_decorator_1 = require("../di/binding-decorator"); /** * Provides a binding for the given identifier. * * @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered. * @returns A fluent interface for further configuring the binding. * * @example * ```typescript * provide(ServiceIdentifier) * class MyService {} * ``` * @public API */ const provide = (identifier) => { return (0, binding_decorator_1.fluentProvide)(identifier).done(); }; exports.provide = provide; /** * Provides a singleton binding for the given identifier. * * Singleton binding ensures that the same instance of a dependency is reused within the entire container. * * @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered. * @returns A fluent interface for further configuring the binding. * * @example * ```typescript * provideSingleton(ServiceIdentifier) * class MyService {} * ``` * @public API */ const provideSingleton = (identifier) => { return (0, binding_decorator_1.fluentProvide)(identifier).inSingletonScope().done(); }; exports.provideSingleton = provideSingleton; /** * Provides a transient binding for the given identifier. * * Transient binding ensures that a new instance of a dependency is created every time it is resolved. * * @param identifier - The identifier (e.g., symbol, string, class) for the dependency being registered. * @returns A fluent interface for further configuring the binding. * * @example * ```typescript * provideTransient(ServiceIdentifier) * class MyService {} * ``` * @public API */ const provideTransient = (identifier) => { return (0, binding_decorator_1.fluentProvide)(identifier).inTransientScope().done(); }; exports.provideTransient = provideTransient;