import Koa from 'koa'; import { Application, HttpServer as HttpServerContract, MiddlewareCtor, HttpRouter, HttpServerHandler, InlineMiddlewareHandler, ApplicationConfig, HttpConfig } from '@supercharge/contracts'; type Callback = (server: Server) => unknown | Promise; export declare class Server implements HttpServerContract { /** * The server’s meta data. */ private readonly meta; /** * Create a new HTTP context instance. */ constructor(app: Application, appConfig: ApplicationConfig, httpConfig: HttpConfig); /** * Returns the initialized Koa instance. */ private createKoaInstance; /** * Register middlware to the HTTP server. */ registerBaseMiddleware(): void; /** * Register the core middleware stack. This is basically a global middleware * stack, but it’s not configurable by the user. Instead, all middleware * registered here will be available out of the box. */ registerCoreMiddleware(): void; /** * Returns an array of middleware that will be registered when creating the HTTP server. */ coreMiddleware(): MiddlewareCtor[]; /** * Returns the Koa application instance. */ koa(): Koa; /** * Returns the HTTP server instance. Returns `undefined ` if the Koa server wasn’t started. */ private startedServer; /** * Register a booted callback that runs after the HTTP server started. */ booted(callback: Callback): this; /** * Returns the booted callbacks. */ private bootedCallbacks; /** * Run the configured `booted` callbacks. */ protected runBootedCallbacks(): Promise; /** * Call the given kernal `callbacks`. */ protected runCallbacks(callbacks: Callback[]): Promise; /** * Returns the application instance. */ app(): Application; /** * Determine whether the HTTP server is already boostrapped. */ isBootstrapped(): boolean; /** * Mark this HTTP server as bootstrapped. */ markAsBootstrapped(): this; /** * Returns the router instance. */ router(): HttpRouter; /** * Clear all registered routes from the router. */ clearRoutes(): this; /** * Register a route-level middleware for the given `name` and `Middleware` to the HTTP router. */ useRouteMiddleware(name: string, Middleware: MiddlewareCtor): this; /** * Add the given `Middleware` as a global middleware to the HTTP server. */ use(Middleware: MiddlewareCtor | InlineMiddlewareHandler): this; /** * Register the given HTTP middleware to the IoC container and HTTP server instance. */ private bindAndRegisterMiddlewareClass; /** * Bind the given `Middleware` into the container if it’s not already bound. */ private bindMiddlewareClass; /** * Ensure that the given `Middleware` implements a `handle` method. */ private ensureHandleMethod; /** * Register the given HTTP middleware to the IoC container and HTTP server instance. */ private registerMiddlewareHandler; /** * Returns a request handler callback compatible with Node.js’ native HTTP server. */ callback(): HttpServerHandler; /** * Bootstrap the HTTP server. */ bootstrap(): void; /** * Wrap the given Koa `ctx` into a Supercharge context. */ private createContext; /** * Register routes to the HTTP server. */ private registerRoutes; /** * Start the HTTP server. */ start(): Promise; /** * Stop the HTTP server from accepting new connections. Existing connections * stay alive and will be processed. The server stops as soon as all open * connections have been processed through the HTTP request lifecycle. */ stop(): Promise; /** * Returns the HTTP cookie configuration object. */ private cookieConfig; /** * Returns the local port on which the server listens for connections. */ private port; /** * Returns the hostname on which the server listens for connections. */ private hostname; } export {};