@glandjs/http
Version:
A protocol adapter for HTTP built on top of the Gland architecture solution.
37 lines (36 loc) • 1.46 kB
TypeScript
import { Logger } from '@medishn/toolkit';
import { HttpEventCore } from './http-events';
import type { CorsConfig, RouteAction } from '../types';
import type { HttpApplicationOptions } from '../interface';
export interface HttpGlandEvents {
options?: HttpApplicationOptions;
'server:crashed': {
message: string;
error: any;
stack: any;
};
}
export declare abstract class HttpServerAdapter<TServer, TAapp, TRequest, TResponse> {
instance: TAapp;
protected logger: Logger;
events: HttpEventCore<HttpGlandEvents>;
protected server: TServer;
constructor(instance: TAapp);
abstract initialize(): Promise<void> | void;
abstract listen(port: string | number, hostname?: string, message?: string): void;
close(): Promise<void>;
abstract use(...args: any): any;
abstract registerRoute(method: string, path: string, action: RouteAction<TRequest, TResponse>): void;
abstract enableCors(options: CorsConfig): void;
abstract setViewEngine(engine: string): this;
abstract setBaseViewsDir(path: string | string[]): this;
abstract setGlobalPrefix(prefix: string): void;
abstract useStaticAssets(path: string, options?: any): void;
abstract json(options?: any): this;
abstract urlencoded(options?: {
extended?: boolean;
}): this;
abstract raw(options?: any): this;
abstract text(options?: any): this;
handleError(error: any, message: string): void;
}