@api.global/typedserver
Version:
A TypeScript-based project for easy serving of static files with support for live reloading, compression, and typed requests.
50 lines (49 loc) • 2.06 kB
TypeScript
import * as plugins from '../plugins.js';
import { Route } from './classes.route.js';
import { Handler } from './classes.handler.js';
import { Sitemap } from './classes.sitemap.js';
import { Feed } from './classes.feed.js';
import { type IServerOptions } from '../classes.typedserver.js';
export type TServerStatus = 'initiated' | 'running' | 'stopped';
/**
* can be used to spawn a server to answer http/https calls
* for constructor options see [[IServerOptions]]
*/
export declare class Server {
httpServer: plugins.http.Server | plugins.https.Server;
expressAppInstance: plugins.express.Application;
routeObjectMap: Route[];
options: IServerOptions;
serverStatus: TServerStatus;
feed: Feed;
sitemap: Sitemap;
executeAfterStartFunctions: (() => Promise<void>)[];
private startedDeferred;
startedPromise: Promise<unknown>;
private socketMap;
constructor(optionsArg: IServerOptions);
/**
* allows updating of server options
* @param optionsArg
*/
updateServerOptions(optionsArg: IServerOptions): void;
addTypedRequest(typedrouter: plugins.typedrequest.TypedRouter): void;
addTypedSocket(typedrouter: plugins.typedrequest.TypedRouter): void;
addRoute(routeStringArg: string, handlerArg?: Handler): Route;
addRouteBefore(routeStringArg: string, handlerArg?: Handler): Route;
/**
* starts the server and sets up the routes
* @param portArg
* @param doListen
*/
start(portArg?: number | string, doListen?: boolean): Promise<void>;
getHttpServer(): plugins.http.Server<typeof plugins.http.IncomingMessage, typeof plugins.http.ServerResponse> | plugins.https.Server<typeof plugins.http.IncomingMessage, typeof plugins.http.ServerResponse>;
getExpressAppInstance(): plugins.express.Application;
stop(): Promise<unknown>;
/**
* allows handling requests and responses that come from other
* @param req
* @param res
*/
handleReqRes(req: plugins.express.Request, res: plugins.express.Response): Promise<void>;
}