/** * This file contains the abstract server adapter class and its related types. * It is designed to be extended by specific server adapters for different runtimes. * The class provides methods for initializing the server, creating server options, * building static files, and handling HTTP requests. * * @module ServerAdapter */ import type { EcoPagesAppConfig } from '../../types/internal-types.js'; import type { ApiHandler } from '../../types/public-types.js'; import type { StaticGenerationRoute } from '../../router/server/route-registry.js'; /** * Configuration options for all server adapters */ export interface ServerAdapterOptions { appConfig: EcoPagesAppConfig; apiHandlers?: ApiHandler[]; options?: { watch?: boolean; [key: string]: any; }; serveOptions?: Record; runtimeOrigin: string; } /** * Base adapter result containing common functionalities * across different runtime implementations */ export interface ServerAdapterResult { getServerOptions: (options?: { enableHmr?: boolean; }) => any; buildStatic: (options?: { preview?: boolean; force?: boolean; }) => Promise; servePreviewOnly: () => Promise; dispose(): Promise; /** * Lists static-generation routes for app-start consumers. * * @remarks * Optional so lightweight adapter stubs in tests need not implement routing. */ listStaticGenerationRoutes?: (input: { runtimeOrigin: string; }) => Promise; } /** * Abstract base class for server adapters across different runtimes */ export declare abstract class AbstractServerAdapter { protected appConfig: EcoPagesAppConfig; protected options: TOptions['options']; protected serveOptions: TOptions['serveOptions']; protected runtimeOrigin: string; constructor(options: TOptions); /** * Initialize the server adapter */ abstract initialize(): Promise; /** * Create server options specific to the runtime */ abstract getServerOptions(options?: { enableHmr?: boolean; }): any; /** * Build static files for the application */ abstract buildStatic(options?: { preview?: boolean; force?: boolean; }): Promise; /** * Factory method to create a server adapter with runtime-specific functionality */ abstract createAdapter(): Promise; /** * Handle HTTP requests */ abstract handleRequest(request: Request): Promise; }