///
import { Injection } from '@thinkbeanie/common';
import { HTTPEndpoint, HTTPService, HTTPServiceClass, HTTPServiceModel } from './internal';
import Koa from 'koa';
import http from 'http';
import { HTTPMiddleware } from './middleware';
export interface HTTPServerOptions {
baseUrl?: string;
port: number;
middlewares?: (HTTPMiddleware | ((ctx: Koa.Context, next: any) => Promise))[];
errorHandlers?: ((err: any, ctx: any) => void)[];
register: (plugin: HTTPServer) => void;
di?: Injection.Injector;
bodyParser?: any;
busboy?: any;
cors?: boolean | {
origin?: string | ((ctx: any) => string);
allowMethods?: string | string[];
exposeHeaders?: string | string[];
allowHeaders?: string | string[];
maxAge?: string | number;
credentials?: boolean | ((ctx: any) => boolean);
keepHeadersOnError?: boolean;
secureContext?: boolean;
privateNetworkAccess?: boolean;
};
}
export declare class HTTPServer {
options: HTTPServerOptions;
protected koa: Koa;
protected router: any;
protected server: http.Server;
protected endpoints: {
[path: string]: {
meta: HTTPEndpoint;
handler: (...args: any[]) => any | Promise;
};
};
protected services: {
[key: string]: {
meta: HTTPServiceModel;
instance: HTTPService;
};
};
private di;
constructor(options: HTTPServerOptions);
start(): Promise;
stop(): Promise;
register(ws: HTTPServiceClass): Promise;
get netServer(): http.Server;
}