opinionated-machine
Version:
Very opinionated DI framework for fastify, built on top of awilix
30 lines (29 loc) • 1.8 kB
TypeScript
import type { AnyDualModeContractDefinition, AnySSEContractDefinition } from '@lokalise/api-contracts';
import type { RouteOptions } from 'fastify';
import type { AbstractDualModeController } from '../dualmode/AbstractDualModeController.ts';
import type { AbstractSSEController } from '../sse/AbstractSSEController.ts';
import type { DualModeRouteHandler, SSERouteHandler } from './fastifyRouteTypes.ts';
import { extractPathTemplate } from './fastifyRouteUtils.ts';
export { extractPathTemplate };
/**
* Build a Fastify route configuration for a dual-mode endpoint.
*
* This overload handles dual-mode route handlers (endpoints that support both sync and SSE responses).
* The response mode is determined by the Accept header.
*
* @param controller - The dual-mode controller instance
* @param handler - The dual-mode route handler (from buildHandler)
* @returns Fastify route options
*/
export declare function buildFastifyRoute<Contracts extends Record<string, AnyDualModeContractDefinition>, Contract extends AnyDualModeContractDefinition>(controller: AbstractDualModeController<Contracts>, handler: DualModeRouteHandler<Contract>): RouteOptions;
/**
* Build a Fastify route configuration for an SSE endpoint.
*
* This overload handles SSE route handlers (endpoints that only stream SSE responses).
* Integrates with @fastify/sse and the AbstractSSEController for connection management.
*
* @param controller - The SSE controller instance
* @param handler - The SSE route handler (from buildHandler)
* @returns Fastify route options
*/
export declare function buildFastifyRoute<Contracts extends Record<string, AnySSEContractDefinition>, Contract extends AnySSEContractDefinition>(controller: AbstractSSEController<Contracts>, handler: SSERouteHandler<Contract>): RouteOptions;