import * as http from 'node:http'; import * as https from 'node:https'; import * as net from 'node:net'; export declare const PROTOCOL_HTTP = "http"; export declare const PROTOCOL_HTTPS = "https"; export declare const DEFAULT_HOST = "0.0.0.0"; export declare const DEFAULT_PORT = 2407; /** * Handler function type that is called with the incomming client request. */ export type Handler = (req: I, res: R) => void; export interface ServerOptions { /** * host address to bind to. */ host?: string; /** * port number to bind to. */ port?: number; } export interface HTTPConfiguration extends ServerOptions, http.ServerOptions { } /** * HTTPSConfiguration for secure http servers. */ export interface HTTPSConfiguration extends ServerOptions, https.ServerOptions { } /** * ServerProtocol indicates which protocol the server should use. */ export type ServerProtocol = 'http' | 'https'; /** * ServerConfiguration */ export interface ServerConfiguration { /** * protocol to use. */ protocol?: ServerProtocol; /** * http configuration to use when HTTP. */ http?: HTTPConfiguration; /** * https configuration to use when HTTPS. */ https?: HTTPSConfiguration; } /** * TendrilServer wraps around an http server to provide stop and restart * facilities. * * This is necessary as node currently provides no way to stop a server * without waiting on clients. */ export declare class TendrilServer { server: net.Server; conf: ServerOptions; sockets: Map; constructor(server: net.Server, conf?: ServerOptions, sockets?: Map); static createInstance(conf: ServerConfiguration, handler: Handler): TendrilServer; /** * start the TendrilServer. * * This will commence listening for connections blocking until the server * has been closed or an error encountered. */ start(): Promise; /** * flush closes all open client connections. * * The server itself is not closed and remains open for new connections. */ flush(): void; /** * stop the TendrilServer. * * Open connections will be forced closed so that the server can exit. */ stop(): Promise; }