import * as http from "http";
import * as https from "https";
import express from "express";
import { Files, Options as FormidableOptions } from "formidable";
import RedisClient from "ioredis";
import { HotServer } from "./HotServer";
import { HotStaq } from "./HotStaq";
import { HotRoute } from "./HotRoute";
import { HotEventMethod } from "./HotRouteMethod";
import { HotWebSocketServer } from "./HotWebSocketServer";
import { HotMCPServer } from "./HotMCPServer";
import { HotLog } from "./HotLog";
/**
 * A static route.
 */
export interface StaticRoute {
    /**
     * The route to the files.
     */
    route?: string;
    /**
     * The absolute path to the location of the files to
     * serve on this machine.
     */
    localPath?: string;
}
/**
 * A HTTP header to send.
 */
export interface HTTPHeader {
    /**
     * The header type. Example: Content-Type
     */
    type: string;
    /**
     * The header value. Example: text/html
     */
    value: string;
}
/**
 * A servable file extension.
 */
export interface ServableFileExtension {
    /**
     * The file extension that includes the period at the beginning.
     *
     * @example .hott
     */
    fileExtension: string;
    /**
     * If set to true, this will generate the content to serve the file.
     * Typically used for .hott files.
     *
     * Default: false
     */
    generateContent?: boolean;
    /**
     * The headers to send with the file extension.
     */
    headers?: HTTPHeader[];
}
/**
 * A HTTP server.
 */
export declare class HotHTTPServer extends HotServer {
    /**
     * The express app to use.
     */
    expressApp: express.Express;
    /**
     * The HTTP listener to use.
     */
    httpListener: http.Server;
    /**
     * The HTTPS listener to use.
     */
    httpsListener: https.Server;
    /**
     * If set to true, the websocket server will be started.
     */
    useWebsocketServer: boolean;
    /**
     * The websocket server to use.
     */
    websocketServer: HotWebSocketServer;
    /**
     * The static files and folders to serve.
     */
    staticRoutes: StaticRoute[];
    /**
     * Any non-static routes that need to be added. These
     * will be added during the preregistration phase, before
     * all API routes are added.
     */
    routes: {
        /**
         * The type of route.
         */
        type: HotEventMethod;
        /**
         * The type of route.
         */
        route: string;
        /**
         * The method to execute when this route is hit.
         */
        method: (req: express.Request, res: express.Response) => Promise<void>;
    }[];
    /**
     * Serve the following file extensions when requested. For any of these to be served
     * there has to be at least one file extension added prior to starting the server.
     * Additional file extensions can be added after server start.
     */
    serveFileExtensions: (string | ServableFileExtension)[];
    /**
     * Do not serve these hott files.
     */
    ignoreHottFiles: {
        [name: string]: boolean;
    };
    /**
     * The associated info with any hott files served. All values here will be
     * overwritten by whatever values are set in the server object in HotSite.json.
     */
    hottFilesAssociatedInfo: {
        /**
         * The default name for a served Hott file.
         */
        name: string;
        /**
         * The base url for a hott file.
         */
        url: string;
        /**
         * The JavaScript source path.
         */
        jsSrcPath: string;
    };
    /**
     * The uploads that have been sent to the server. Each key is an upload id that
     * has a list of file paths where the files can be retreived.
     */
    uploads: {
        [uploadId: string]: {
            [key: string]: {
                name: string;
                size: number;
                path: string;
            };
        };
    };
    /**
     * Auto delete upload options.
     */
    autoDeleteUploadOptions: {
        afterUploadIdUse: boolean;
    };
    /**
     * The request reporter interval.
     */
    requestReporterInterval: NodeJS.Timeout;
    /**
     * The number of requests served, this will be incremented each time a request is served,
     * and if it reaches (Number.MAX_SAFE_INTEGER - 1), it will be reset to 0.
     */
    numRequestsServed: number;
    /**
     * The active requests being processed currently.
     */
    activeRequests: {
        [requestNum: number]: DOMHighResTimeStamp;
    };
    /**
     * If set to true, worker threads will be used. NOT WORKING YET. DO NOT USE.
     */
    useWorkerThreads: boolean;
    /**
     * The Swagger UI setttings.
     */
    swaggerUI: {
        /**
         * If set, this will start Swagger UI from either the JSON or YAML file provided.
         * If this is set to a file ending with either .yml or .yaml it will be converted to JSON.
         */
        filepath: string;
        /**
         * The route to use.
         * @default /swagger
         */
        route: string;
        /**
         * The loaded YAML or JSON.
         */
        jsonObj: any;
    };
    /**
     * The MCP (Model Context Protocol) server settings.
     */
    mcpServer: {
        /**
         * If set to true, the MCP server will be enabled.
         * @default false
         */
        enabled: boolean;
        /**
         * The route to expose the MCP server on.
         * @default "/mcp"
         */
        route: string;
        /**
         * The MCP server instance.
         */
        server: HotMCPServer | null;
    };
    /**
     * The options to use when a new client has made a request.
     */
    options: {
        /**
         * Executes when the new client has requested the headers.
         */
        onCall: (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>;
        /**
         * The headers to send with the response. Default:
         * [
         *	 { type: "Access-Control-Allow-Origin", value: "*" },
         *	 { type: "Access-Control-Allow-Methods", value: "GET,HEAD,PUT,PATCH,POST,DELETE" },
         *	 { type: "Access-Control-Allow-Headers", value: "Origin, X-Requested-With, Content-Type, Accept" }
         * ]
         */
        headers: HTTPHeader[];
    };
    /**
     * The CORS settings. By default the origin will be open to all.
     * The CORS settings that are set here will also be used for the
     * websocket server as well.
     */
    cors: {
        /**
         * Executed when a CORS call has been made.
         */
        onCORSCall: (req: express.Request, res: express.Response, next: express.NextFunction) => Promise<void>;
        /**
         * The allowed CORS origins. Default: *
         */
        origin: string;
        /**
         * The allowed headers. Default: ["Origin", "X-Requested-With", "Content-Type", "Accept"]
         */
        allowedHeaders: string[];
    };
    /**
     * The rate limiter settings. This is a fairly simple rate limiter, for more
     * complex scenarios you may have to customize the rate limiter by attaching it to
     * this.expressApp directly. This uses express-rate-limit.
     */
    rateLimiter: {
        /**
         * If set to true, the rate limiter will be enabled. By default it will be
         * true only if there's an API attached. Otherwise false.
         *
         * @default false
         */
        enabled: boolean;
        /**
         * The number of milliseconds to remember requests for.
         *
         * @default 60000
         */
        windowLength: number;
        /**
         * The number of requests allowed per window.
         *
         * @default 500
         */
        limit: number;
        /**
         * The store to use for the rate limiter. For now, this requires Redis.
         */
        store: {
            /**
             * The Redis client to use. You can use a custom client here
             * or use the default client provided by ioredis by setting
             * the redisConfig below.
             */
            redisClient: RedisClient;
            /**
             * The Redis config. By default this is null, if a host is
             * entered, the default port will be 6379 if left empty.
             * The username and password will not be used by default.
             */
            redisConfig: {
                host?: string;
                port?: number;
                username?: string;
                password?: string;
                tls?: boolean;
                tlsInsecure?: boolean;
            };
        };
    };
    /**
     * The function to execute when handling 404 errors.
     */
    handle404: (req: express.Request, res: express.Response, next: any) => void;
    /**
     * The function to execute when handling other errors.
     */
    handleOther: (err: any, req: express.Request, res: express.Response, next: any) => void;
    /**
     * The status code to respond with when an API error occurs.
     */
    errorHandlingResponseCode: number;
    constructor(processor: HotStaq | HotServer, httpPort?: number, httpsPort?: number);
    /**
     * Get the method name to be used with Express.
     */
    static getExpressMethodName(methodType: HotEventMethod): string;
    /**
     * Get the default servable file extensions.
     */
    static getDefaultServableExtensions(): ServableFileExtension[];
    /**
     * Add a static route.
     */
    addStaticRoute(route: string | StaticRoute, localPath?: string): void;
    /**
     * Add a route. This will be registered before any APIs are registered.
     */
    addRoute(route: string, method: (req: express.Request, res: express.Response) => Promise<void>, type?: HotEventMethod): void;
    /**
     * Serve a directory. This is an alias for addStaticRoute.
     */
    serveDirectory(route: string | StaticRoute, localPath?: string): void;
    /**
     * Register a static route with Express.
     */
    registerStaticRoute(route: StaticRoute): void;
    /**
     * Get a static route.
     */
    getStaticRoute(route: string): StaticRoute;
    /**
     * Register a route.
     */
    registerRoute(route: HotRoute): Promise<void>;
    /**
     * Check if a file exists.
     */
    static checkIfFileExists(filepath: string): Promise<boolean>;
    /**
     * Delete the uploads for a given upload id.
     */
    deleteUploads(uploadId: string): Promise<void>;
    /**
     * The routes to add before registering a route.
     */
    preregisterRoute(): void;
    /**
     * Get all files uploaded.
     */
    static getFileUploads(logger: HotLog, req: express.Request, options?: FormidableOptions): Promise<Files>;
    /**
     * Set the error handlers. This will create two express routes at the bottom of the
     * route stack. The first will be to capture any 404 errors, the second would be to
     * catch any remaining errors.
     */
    setErrorHandlingRoutes(): void;
    /**
     * Clear the last two express routes, which are reserved for the
     * error handlers.
     */
    clearErrorHandlingRoutes(): void;
    /**
     * Start listening for requests.
     */
    listen(): Promise<void>;
    /**
     * Start the server.
     *
     * @param localStaticPath The public path that contains the HTML, Hott files, images, and
     * all public content. This can also be an array of StaticRoutes.
     * @param httpPort The HTTP port to listen on .
     * @param httpsPort The HTTPS port to listen on.
     * @param processor The HotStaq or parent server being used for communication.
     */
    static startServer(localStaticPath?: string | StaticRoute[], httpPort?: number, httpsPort?: number, processor?: HotServer | HotStaq): Promise<{
        processor: HotServer | HotStaq;
        server: HotHTTPServer;
    }>;
    /**
     * Is this server running with an API server?
     */
    isAPIServerOnly(): boolean;
    /**
     * Is this server running with an API server?
     */
    isAPIServerRunning(): boolean;
    /**
     * Shutdown the server.
     */
    shutdown(): Promise<void>;
}
//# sourceMappingURL=HotHTTPServer.d.ts.map