UNPKG

phecda-server

Version:

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

95 lines (90 loc) 2.88 kB
import { Events, Construct } from 'phecda-core'; declare const ERROR_SYMBOL = "__PS_ERROR__"; declare const IS_DEV: 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, CustomResponse as C, type DefaultOptions as D, type Emitter as E, IS_DEV as I, LOG_LEVEL as L, Meta as M, PS_EXIT_CODE as P, type ServiceMetaData as S, type ControllerMeta as a, type BaseError as b, type ControllerMetaData as c, type BaseRequestMethod as d, type ExtractResponse as e, type MetaData as f, ERROR_SYMBOL as g, IS_ONLY_GENERATE as h, IS_STRICT as i, IS_PURE as j };