UNPKG

opinionated-machine

Version:

Very opinionated DI framework for fastify, built on top of awilix

27 lines 850 B
import { asFunction } from 'awilix'; /** * Register an `AbstractApiController` subclass with the awilix DI container. * * The returned resolver does **not** set `isSSEController` or `isDualModeController`, * so `DIContext` reads its `routes` property automatically during `registerRoutes()`. * * @example * ```typescript * // In a module's resolveControllers(): * return { * userController: asApiControllerClass(UserController), * } * ``` */ export function asApiControllerClass(Type, opts) { const Ctor = Type; return asFunction( // biome-ignore lint/suspicious/noExplicitAny: Dynamic constructor invocation with cradle proxy (cradle) => new Ctor(cradle), { public: false, isApiController: true, ...opts, lifetime: 'SINGLETON', }); } //# sourceMappingURL=asApiControllerClass.js.map