import { Injectable , depend } from 'velona' ; import type { FastifyInstance , onRequestHookHandler , preParsingHookHandler , preValidationHookHandler , preHandlerHookHandler } from 'fastify' ; import type { Schema } from 'fast-json-stringify' ; import type { HttpStatusOk } from 'aspida' ; import type { ServerMethods } from '../../$server' ; import type { Methods } from './' ; type Hooks = { onRequest ? : onRequestHookHandler | onRequestHookHandler [ ] ; preParsing ? : preParsingHookHandler | preParsingHookHandler [ ] ; preValidation ? : preValidationHookHandler | preValidationHookHandler [ ] ; preHandler ? : preHandlerHookHandler | preHandlerHookHandler [ ] ; } ; type ControllerMethods = ServerMethods < Methods > ; export function defineResponseSchema < T extends { [ U in keyof ControllerMethods ] ? : { [ V in HttpStatusOk ] ? : Schema ; } ; } > ( methods ) { return methods ; } export function defineHooks < T extends Hooks > ( hooks ) ; export function defineHooks < T extends Record < string , any > , U extends Hooks > ( deps , cb ) ; export function defineHooks < T extends Record < string , any > > ( hooks , cb ? ) { return cb && typeof hooks !== 'function' ? depend ( hooks , cb ) : hooks ; } export function defineController ( methods ) ; export function defineController < T extends Record < string , any > > ( deps , cb ) ; export function defineController < T extends Record < string , any > > ( methods , cb ? ) { return cb && typeof methods !== 'function' ? depend ( methods , cb ) : methods ; }