/** * Standard Server Implementation * A simplified, consistent server pattern for all SuperDangerous applications * Combines the best of StartupOrchestrator with the simplicity apps need */ import { Express } from "express"; import { Server as HttpServer } from "http"; import { Server as HttpsServer } from "https"; import { createRequestLoggingMiddleware } from "../middleware/requestLogging.js"; export interface StandardServerConfig { appName: string; appVersion: string; description?: string; port?: number; webPort?: number; host?: string; environment?: string; enableWebSocket?: boolean; /** * When true (default), startup failures will terminate the Node process. * Disable in test environments to surface errors as rejections instead. */ exitOnStartupError?: boolean; logging?: { level?: string; maxSize?: string; maxFiles?: string | number; datePattern?: string; zippedArchive?: boolean; }; appId?: string; enableDesktopIntegration?: boolean; desktopDataPath?: string; corsOrigins?: string[]; onInitialize?: (app: Express, io?: any) => Promise; onStart?: () => Promise; /** * Request payload size limit passed to express.json/urlencoded */ bodyLimit?: string | number; /** * Whether to log requests using the framework logger (defaults to true) */ enableRequestLogging?: boolean; /** * Options forwarded to the request logging middleware */ requestLogging?: Parameters[0]; /** * Configure trust proxy setting for Express (defaults to true for prod) */ trustProxy?: boolean | string; /** * Custom timeouts for the underlying HTTP server */ requestTimeoutMs?: number; headersTimeoutMs?: number; keepAliveTimeoutMs?: number; /** * Signals that should trigger a graceful shutdown. Set to [] to disable. */ gracefulShutdownSignals?: NodeJS.Signals[]; } /** * Standard server implementation that all apps should use * Handles startup, error handling, and banner display consistently */ export declare class StandardServer { private app; private httpServer; private config; private wsServer; private startTime; private isInitialized; private shuttingDown; private signalsBound; private connections; constructor(config: StandardServerConfig); /** * Get the Express app instance for middleware setup */ getApp(): Express; /** * Get the HTTP server instance */ getServer(): HttpServer | HttpsServer; /** * Initialize the server (setup middleware, routes, etc.) */ initialize(): Promise; /** * Setup desktop app integration (CORS, data paths, logging, etc.) */ private setupDesktopIntegration; /** * Setup default middleware for all applications */ private setupDefaultMiddleware; /** * Setup error handlers (should be last in middleware chain) */ private setupErrorHandlers; /** * Start the server and listen on the configured port */ start(): Promise; /** * Get the data path for desktop apps (platform-specific) */ getDataPath(): string; /** * Check if running as desktop app */ isDesktopApp(): boolean; /** * Attach signal listeners for graceful shutdown */ private bindShutdownSignals; /** * Stop the server gracefully */ stop(): Promise; private forceCloseConnections; } /** * Convenience function to create and start a standard server */ export declare function createStandardServer(config: StandardServerConfig): Promise; //# sourceMappingURL=StandardServer.d.ts.map