UNPKG

phecda-server

Version:

server framework that provide IOC/type-reuse/http&rpc-adaptor

95 lines (90 loc) 2.89 kB
import { Events, Construct } from 'phecda-core'; declare const ERROR_SYMBOL = "__PS_ERROR__"; declare const IS_RUNTIME: boolean; declare const IS_ONLY_GENERATE: boolean; declare const IS_STRICT: boolean; declare const IS_PURE: boolean; declare const LOG_LEVEL: number; declare enum PS_EXIT_CODE { RELAUNCH = 4171, EXIT = 4172 } interface Emitter { on<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void; once<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void; off<N extends keyof Events>(eventName: N, cb: (args: Events[N]) => void): void; removeAllListeners<N extends keyof Events>(eventName: N): void; emit<N extends keyof Events>(eventName: N, param: Events[N]): void; } interface BaseCtx { meta: ControllerMeta; moduleMap: Record<string, any>; type: string; tag: string; method: string; category: string; [key: string]: any; } interface DefaultOptions { globalGuards?: string[]; globalFilter?: string; globalPipe?: string; globalAddons?: string[]; } interface BaseError { [ERROR_SYMBOL]: true; status: number; message: string; description: string; } type BaseRequestMethod = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options'; declare class CustomResponse<Value> { _ps_response: Value; } type ExtractResponse<Class extends CustomResponse<any>> = Class extends CustomResponse<infer Value> ? Value : never; interface ServiceMetaData { method: string; name: string; tag: string; define?: any; meta: any; [key: string]: any; } interface ControllerMetaData extends ServiceMetaData { controller: string; http?: { method: BaseRequestMethod; prefix: string; route: string; headers?: Record<string, string>; }; rpc?: { queue?: string; isEvent?: boolean; }; ctxs?: string[]; params: { type: string; index: number; key: string; pipe?: string; define: Record<string, any>; meta: any; }[]; guards: string[]; pipe?: string; filter?: string; addons: string[]; } type MetaData = ControllerMetaData | ServiceMetaData; declare class Meta { data: MetaData; paramsType: any[]; module: any; model: Construct; constructor(data: MetaData, paramsType: any[], module: any, model: Construct); } interface ControllerMeta extends Meta { data: ControllerMetaData; } export { type BaseCtx as B, type ControllerMeta as C, type DefaultOptions as D, type Emitter as E, IS_ONLY_GENERATE as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type BaseError as a, type ControllerMetaData as b, type BaseRequestMethod as c, CustomResponse as d, ERROR_SYMBOL as e, type ExtractResponse as f, IS_PURE as g, IS_RUNTIME as h, IS_STRICT as i, type MetaData as j };