| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- // Generated by dts-bundle-generator v9.5.1
- import { NextFunction as ExpressNextFunction, Request as ExpressRequest, Response as ExpressResponse } from 'express';
- import { WebSocket as WS } from 'ws';
- export declare abstract class HttpHandler {
- protected abstract route: string | null;
- protected abstract action: (...any: any[]) => any;
- protected context: any;
- constructor(context: Record<string, any>);
- setContext(context: Record<string, any>): HttpHandler;
- getContext(): Record<string, any>;
- getRoute(): string | null;
- getAction(): (...any: any[]) => any;
- }
- export declare enum HttpMethod {
- GET = 0,
- POST = 1
- }
- export declare abstract class Middleware extends HttpHandler {
- protected abstract order: number;
- protected abstract action: (...any: any[]) => any;
- getOrder(): number;
- }
- interface Request$1 extends ExpressRequest {
- }
- interface Response$1 extends ExpressResponse {
- }
- export declare abstract class Route extends HttpHandler {
- protected abstract method: HttpMethod;
- protected abstract action: (req: Request$1, res: Response$1) => any;
- protected get documentation(): string;
- getMethod(): HttpMethod;
- getDocumentation(): string;
- }
- export declare enum StatusCodes {
- CONTINUE = 100,
- SWITCHING_PROTOCOLS = 101,
- OK = 200,
- CREATED = 201,
- ACCEPTED = 202,
- NON_AUTHORITATIVE_INFORMATION = 203,
- NO_CONTENT = 204,
- RESET_CONTENT = 205,
- PARTIAL_CONTENT = 206,
- MULTIPLE_CHOICES = 300,
- MOVED_PERMANENTLY = 301,
- MOVED_TEMPORARILY = 302,
- SEE_OTHER = 303,
- NOT_MODIFIED = 304,
- USE_PROXY = 305,
- TEMPORARY_REDIRECT = 307,
- BAD_REQUEST = 400,
- UNAUTHORIZED = 401,
- PAYMENT_REQUIRED = 402,
- FORBIDDEN = 403,
- NOT_FOUND = 404,
- METHOD_NOT_ALLOWED = 405,
- NOT_ACCEPTABLE = 406,
- PROXY_AUTHENTICATION_REQUIRED = 407,
- REQUEST_TIMEOUT = 408,
- CONFLICT = 409,
- GONE = 410,
- LENGTH_REQUIRED = 411,
- PRECONDITION_FAILED = 412,
- REQUEST_ENTITY_TOO_LARGE = 413,
- REQUEST_URI_TOO_LONG = 414,
- UNSUPPORTED_MEDIA_TYPE = 415,
- REQUESTED_RANGE_NOT_SATISFIABLE = 416,
- EXPECTATION_FAILED = 417,
- INTERNAL_SERVER_ERROR = 500,
- NOT_IMPLEMENTED = 501,
- BAD_GATEWAY = 502,
- SERVICE_UNAVAILABLE = 503,
- GATEWAY_TIMEOUT = 504,
- HTTP_VERSION_NOT_SUPPORTED = 505
- }
- export interface NextFunction extends ExpressNextFunction {
- }
- export declare class Logger {
- private getTime;
- private log;
- info(message: string): void;
- error(message: string): void;
- warn(message: string): void;
- }
- export type Message = {
- type: string;
- text: string;
- };
- export declare abstract class WebSocketHandler {
- static Event: {
- CONNECTION: string;
- MESSAGE: string;
- CLOSE: string;
- ERROR: string;
- };
- abstract onConnect: (ws: WS) => any;
- abstract onMessage: (message: string) => any;
- abstract onError: () => any;
- abstract onClose: (code?: number, reason?: string) => any;
- }
- export type ServerProperties = {
- port: number;
- host?: string;
- middlewaresPath?: string;
- sessions?: boolean;
- routesPath?: string;
- json?: boolean;
- urlencoded?: boolean;
- locale?: string;
- i18nPath?: string;
- viewEngine?: string;
- viewsPath?: string;
- swagger?: {
- docsPath?: string;
- title?: string;
- version?: string;
- route?: string;
- description?: string;
- components?: object;
- security?: object;
- };
- wsHandlers?: {
- [url: string]: WebSocketHandler;
- };
- options?: {
- [key: string]: any;
- };
- };
- declare abstract class Registry {
- private static httpHandlers;
- private server;
- protected abstract registerRoutes(): Promise<Registry>;
- protected abstract registerMiddlewares(): Promise<Registry>;
- registerHttpHandlers(): Promise<Registry>;
- protected registerHttpHandler(handler: HttpHandler): Registry;
- setServer(server: Server): Registry;
- getServer(): Server | null;
- static getHttpHandlers(): HttpHandler[];
- }
- /** @sealed */
- export declare class Server {
- private instance;
- private httpServer;
- private readonly port;
- private readonly host;
- private readonly logger;
- private i18n;
- private readonly wsHandlers;
- private readonly wsServers;
- private initialized;
- private readonly i18nPath?;
- private readonly middlewaresPath?;
- private readonly routesPath?;
- private readonly viewEngine?;
- private readonly viewsPath?;
- private readonly options?;
- private readonly swaggerComponents?;
- private readonly swaggerSecurity?;
- private readonly swaggerDocsPath?;
- private readonly swaggerTitle?;
- private readonly swaggerDescription?;
- private readonly swaggerApiVersion?;
- private readonly swaggerRoute?;
- static registry: Registry;
- private readonly systemRegistry;
- constructor(properties: ServerProperties);
- private init;
- private postInit;
- private processHttpHandlers;
- addMiddleware(middleware: Middleware): Server;
- addRoute(route: Route): Server;
- private registerRoutesDocumentation;
- registerWsServers(): Server;
- applyWsHandlers(): Server;
- getWsConnections(url: string): Set<WS> | null;
- logInfo(message: string): void;
- logError(message: string): void;
- logWarn(message: string): void;
- log(message: Message): void;
- private get;
- private post;
- getLogger(): Logger;
- i18nLoad(path: string): Server;
- getHost(): string;
- getOption(key: string): any;
- start(callback?: () => any): Promise<Server>;
- }
- export declare class IncorrectMethodException extends Error {
- constructor();
- }
- export declare class InvalidMiddlewareException extends Error {
- constructor(file: string);
- }
- export declare class InvalidRouteException extends Error {
- constructor(file: string);
- }
- export declare class RouteNotSetException extends Error {
- constructor();
- }
- export declare class ServerNotInitializedException extends Error {
- constructor();
- }
- export declare class Guid {
- static new(): string;
- }
- export type i18nMap = {
- [key: string]: {
- [key: string]: string;
- };
- };
- export type KeyParams = {
- [key: string]: any;
- };
- export declare class i18nLoader {
- private static instance;
- private readonly map;
- private locale;
- static defaultLocale: string;
- constructor(locale: string);
- static getInstance(locale?: string): i18nLoader;
- setLocale(locale: string): i18nLoader;
- load(...paths: string[]): i18nLoader;
- loadJson(obj: i18nMap): i18nLoader;
- get(key: string): string;
- }
- export declare const $: (key: string, params?: KeyParams) => string;
- export declare enum SwaggerParameterIn {
- PATH = "path",
- QUERY = "query",
- HEADER = "header",
- COOKIE = "cookie",
- BODY = "body",
- REQUEST_BODY = "requestBody"
- }
- export type SwaggerSchema = {
- type: string;
- description?: string;
- example?: string;
- items?: SwaggerSchema[];
- properties?: {
- [name: string]: SwaggerSchema;
- };
- };
- export type SwaggerParameter = {
- in: SwaggerParameterIn;
- name: string;
- required: boolean;
- description: string;
- schema?: SwaggerSchema;
- };
- export type SwaggerRequestBodyContent = {
- mediaType: string;
- schema: SwaggerSchema;
- };
- export type SwaggerRequestBody = {
- required: boolean;
- description: string;
- content: SwaggerRequestBodyContent;
- };
- export type SwaggerResponseContent = {
- mediaType: string;
- schema: SwaggerSchema;
- };
- export type SwaggerResponse = {
- code: number;
- description: string;
- content?: SwaggerResponseContent;
- };
- export declare class SwaggerDoc {
- private method;
- private route?;
- private summary?;
- private description?;
- private requestBody?;
- private parameters;
- private responses;
- private security;
- static get(route: string): SwaggerDoc;
- static post(route: string): SwaggerDoc;
- private constructor();
- private setRoute;
- setSummary(summary: string): SwaggerDoc;
- setDescription(description: string): SwaggerDoc;
- setRequestBody(requestBody: SwaggerRequestBody): SwaggerDoc;
- addParameter(param: SwaggerParameter): SwaggerDoc;
- addResponse(res: SwaggerResponse): SwaggerDoc;
- addSecurityScheme(scheme: string): SwaggerDoc;
- toAnnotation(): string;
- private getMethod;
- private deserializeSchema;
- private repeatStr;
- }
- export {
- Request$1 as Request,
- Response$1 as Response,
- };
- export {};
|