UNPKG

@webda/shell

Version:

Deploy a Webda app or configure it

93 lines (92 loc) 2.34 kB
import { ResourceService, WebContext, Core as Webda } from "@webda/core"; import * as http from "http"; export declare enum ServerStatus { Stopped = "STOPPED", Stopping = "STOPPING", Starting = "STARTING", Started = "STARTED" } export declare class WebdaServer extends Webda { private http; private io; protected devMode: boolean; protected serverStatus: ServerStatus; protected subnetChecker: (address: string) => boolean; /** * Resource services used to serve static content */ protected resourceService: ResourceService; /** * Toggle DevMode * * In DevMode CORS is allowed * @param devMode */ setDevMode(devMode: boolean): void; /** * Return true if devMode is enabled * @returns */ isDebug(): boolean; output(...args: any[]): void; /** * Check if a proxy is a trusted proxy * @param ip * @returns */ isProxyTrusted(ip: string): boolean; /** * Return a Context object based on a request * @param req to initiate object from * @param res to add for body * @returns */ getContextFromRequest(req: http.IncomingMessage, res?: http.ServerResponse): Promise<WebContext<any, any>>; /** * Manage the request * * @param req * @param res * @param next */ handleRequest(req: http.IncomingMessage, res: http.ServerResponse): Promise<void>; /** * @override */ flushHeaders(ctx: WebContext): void; /** * @override */ flush(ctx: WebContext): void; /** * @override */ init(): Promise<void>; /** * Start listening to serve request * * @param port to listen to * @param bind address to bind */ serve(port?: number, bind?: string): Promise<void>; /** * Close server and exit */ onSIGINT(): void; /** * Get server status */ getServerStatus(): ServerStatus; /** * Wait for the server to be in a desired state * * @param status to wait for * @param timeout max number of ms to wait for */ waitForStatus(status: ServerStatus.Stopped | ServerStatus.Started, timeout?: number): Promise<any>; stopHttp(): Promise<void>; /** * Stop the http server */ stop(): Promise<void>; }