import type { FastifyInstance } from 'fastify';

export interface SwaggerOptions {
  title: string;
  description?: string;
  port?: number;
}

export interface ReadinessOptions {
  path?: string;
  initialReady?: boolean;
}

export interface ErrorResponseOptions {
  includeRequestId?: boolean;
}

export interface ServiceAppOptions {
  name: string;
  version: string;
  description?: string;
  corsOrigin?: string;
  logger?: boolean;
  logLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
  swagger?: SwaggerOptions;
  metrics?: boolean;
  readiness?: boolean | ReadinessOptions;
  errorResponses?: ErrorResponseOptions;
  optionalPluginFailure?: 'warn' | 'throw';
}

export interface StartOptions {
  port: number;
  host?: string;
  exitOnFatal?: boolean;
  registerSignalHandlers?: boolean;
}

export type FastifyApp = FastifyInstance & {
  setReadyState: (ready: boolean) => void;
  isReadyState: () => boolean;
};
