phecda-server 4.0.0-alpha.7 → 4.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-4ded7d17.d.ts +21 -0
- package/dist/index.d.ts +53 -48
- package/dist/index.js +148 -385
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -374
- package/dist/index.mjs.map +1 -1
- package/dist/rpc/rabbitmq/index.d.ts +4 -28
- package/dist/rpc/rabbitmq/index.js +45 -67
- package/dist/rpc/rabbitmq/index.js.map +1 -1
- package/dist/rpc/rabbitmq/index.mjs +45 -59
- package/dist/rpc/rabbitmq/index.mjs.map +1 -1
- package/dist/rpc/redis/index.d.ts +4 -28
- package/dist/rpc/redis/index.js +52 -74
- package/dist/rpc/redis/index.js.map +1 -1
- package/dist/rpc/redis/index.mjs +52 -66
- package/dist/rpc/redis/index.mjs.map +1 -1
- package/dist/server/express/index.d.ts +23 -0
- package/dist/server/express/index.js +495 -0
- package/dist/server/express/index.js.map +1 -0
- package/dist/server/express/index.mjs +464 -0
- package/dist/server/express/index.mjs.map +1 -0
- package/dist/server/fastify/index.d.ts +22 -0
- package/dist/server/fastify/index.js +466 -0
- package/dist/server/fastify/index.js.map +1 -0
- package/dist/server/fastify/index.mjs +441 -0
- package/dist/server/fastify/index.mjs.map +1 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.js +17 -11
- package/dist/test.js.map +1 -1
- package/dist/test.mjs +17 -11
- package/dist/test.mjs.map +1 -1
- package/dist/{types-ff44d472.d.ts → types-754ec28e.d.ts} +5 -20
- package/package.json +18 -2
- package/dist/core-72b1280e.d.ts +0 -48
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { P, a as Emitter, C as Construct } from './types-754ec28e.js';
|
|
2
|
+
|
|
3
|
+
declare class Meta {
|
|
4
|
+
data: P.Meta;
|
|
5
|
+
handlers: P.Handler[];
|
|
6
|
+
paramsType: any[];
|
|
7
|
+
constructor(data: P.Meta, handlers: P.Handler[], paramsType: any[]);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const emitter: Emitter;
|
|
11
|
+
declare function Factory(Modules: (new (...args: any) => any)[], opts?: {
|
|
12
|
+
http?: string;
|
|
13
|
+
rpc?: string;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
moduleMap: Map<string, any>;
|
|
16
|
+
meta: Meta[];
|
|
17
|
+
constructorMap: Map<any, any>;
|
|
18
|
+
update: (Module: Construct) => Promise<void>;
|
|
19
|
+
}>;
|
|
20
|
+
|
|
21
|
+
export { Factory as F, Meta as M, emitter as e };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
import { B as BaseContext, F as Factory } from './core-72b1280e.js';
|
|
5
|
-
export { e as emitter } from './core-72b1280e.js';
|
|
1
|
+
import { E as Exception, P } from './types-754ec28e.js';
|
|
2
|
+
export { B as BaseError, C as Construct, a as Emitter, M as MergeType, R as RequestType, S as ServerErr, T as ToInstance } from './types-754ec28e.js';
|
|
3
|
+
export { F as Factory, M as Meta, e as emitter } from './core-4ded7d17.js';
|
|
6
4
|
export * from 'phecda-core';
|
|
7
5
|
|
|
6
|
+
declare class Histroy {
|
|
7
|
+
guard: string[];
|
|
8
|
+
interceptor: string[];
|
|
9
|
+
record(name: string, type: 'guard' | 'interceptor'): boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
declare class UndefinedException extends Exception {
|
|
9
13
|
constructor(message: string);
|
|
10
14
|
}
|
|
@@ -61,39 +65,39 @@ declare class FrameworkException extends Exception {
|
|
|
61
65
|
constructor(message: string);
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
declare const guardsRecord: Record<string, P.Guard<
|
|
65
|
-
declare
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
};
|
|
68
|
+
declare const guardsRecord: Record<string, P.Guard<any>>;
|
|
69
|
+
declare class Context<Data = any> {
|
|
70
|
+
tag: string;
|
|
71
|
+
data: Data;
|
|
72
|
+
method: string;
|
|
73
|
+
params: string[];
|
|
74
|
+
history: Histroy;
|
|
75
|
+
static filter: P.Filter;
|
|
76
|
+
static pipe: P.Pipe;
|
|
77
|
+
static guardsRecord: Record<string, P.Guard>;
|
|
78
|
+
static interceptorsRecord: Record<string, P.Interceptor>;
|
|
76
79
|
static middlewareRecord: Record<string, (...params: any) => any>;
|
|
77
|
-
guardsRecord: Record<string, P.Guard<ServerCtx>>;
|
|
78
|
-
interceptorsRecord: Record<string, P.Interceptor<ServerCtx>>;
|
|
79
80
|
postInterceptors: Function[];
|
|
81
|
+
constructor(tag: string, data: Data);
|
|
82
|
+
usePipe(args: {
|
|
83
|
+
arg: any;
|
|
84
|
+
option?: any;
|
|
85
|
+
type: string;
|
|
86
|
+
key: string;
|
|
87
|
+
index: number;
|
|
88
|
+
reflect: any;
|
|
89
|
+
}[]): Promise<any[]>;
|
|
90
|
+
useFilter(arg: any): any;
|
|
91
|
+
useGuard(guards: string[]): Promise<void>;
|
|
92
|
+
usePostInterceptor(ret: any): Promise<any>;
|
|
93
|
+
useInterceptor(interceptors: string[]): Promise<true | undefined>;
|
|
80
94
|
static useMiddleware(middlewares: string[]): ((...params: any) => any)[];
|
|
81
95
|
}
|
|
82
|
-
declare function addMiddleware(key: string, handler:
|
|
83
|
-
declare function setPipe(pipe: P.Pipe
|
|
84
|
-
declare function setFilter(filter: P.Filter
|
|
85
|
-
declare function addGuard(key: string, handler: P.Guard
|
|
86
|
-
declare function addInterceptor(key: string, handler: P.Interceptor
|
|
87
|
-
|
|
88
|
-
interface Options {
|
|
89
|
-
route?: string;
|
|
90
|
-
globalGuards?: string[];
|
|
91
|
-
globalInterceptors?: string[];
|
|
92
|
-
middlewares?: string[];
|
|
93
|
-
parallel?: boolean;
|
|
94
|
-
series?: boolean;
|
|
95
|
-
}
|
|
96
|
-
declare function bindApp(app: Router, { moduleMap, meta }: Awaited<ReturnType<typeof Factory>>, options?: Options): void;
|
|
96
|
+
declare function addMiddleware(key: string, handler: (...params: any) => any): void;
|
|
97
|
+
declare function setPipe(pipe: P.Pipe): void;
|
|
98
|
+
declare function setFilter(filter: P.Filter): void;
|
|
99
|
+
declare function addGuard(key: string, handler: P.Guard): void;
|
|
100
|
+
declare function addInterceptor(key: string, handler: P.Interceptor): void;
|
|
97
101
|
|
|
98
102
|
declare function BaseParam(type: string, key: string, option?: any): any;
|
|
99
103
|
declare function Body(key?: string, pipeOpts?: any): any;
|
|
@@ -109,7 +113,8 @@ declare function Put(route: string): any;
|
|
|
109
113
|
declare function Patch(route: string): any;
|
|
110
114
|
declare function Delete(route: string): any;
|
|
111
115
|
declare function Controller(route: string): any;
|
|
112
|
-
declare function Rpc(...
|
|
116
|
+
declare function Rpc(...types: ('mq' | 'redis' | string)[]): (target: any, key?: PropertyKey) => void;
|
|
117
|
+
declare function Event(isEvent?: boolean): (target: any, key?: PropertyKey) => void;
|
|
113
118
|
|
|
114
119
|
declare function Guard(...guards: string[]): any;
|
|
115
120
|
declare function Middle(...middlewares: string[]): any;
|
|
@@ -134,35 +139,35 @@ declare class Dev {
|
|
|
134
139
|
onUnmount(cb: () => void): void;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
declare abstract class
|
|
138
|
-
|
|
142
|
+
declare abstract class PFilter {
|
|
143
|
+
constructor();
|
|
144
|
+
abstract use<C, S, E extends Exception>(error: Error | E, tag?: string, ctx?: C): S;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare abstract class PGuard {
|
|
148
|
+
abstract use<C>(tag: string, ctx: C): Promise<boolean> | boolean;
|
|
139
149
|
constructor(tag: string);
|
|
140
150
|
}
|
|
141
151
|
|
|
142
|
-
declare abstract class
|
|
143
|
-
abstract use(tag: string, ctx:
|
|
152
|
+
declare abstract class PInterceptor {
|
|
153
|
+
abstract use<C>(tag: string, ctx: C): ((arg: any) => any) | void;
|
|
144
154
|
constructor(tag: string);
|
|
145
155
|
}
|
|
146
156
|
|
|
147
|
-
declare abstract class
|
|
157
|
+
declare abstract class PPipe {
|
|
148
158
|
constructor();
|
|
149
|
-
abstract use(args: {
|
|
159
|
+
abstract use<C>(args: {
|
|
150
160
|
arg: any;
|
|
151
161
|
option?: any;
|
|
152
162
|
key: string;
|
|
153
163
|
type: string;
|
|
154
164
|
index: number;
|
|
155
165
|
reflect: any;
|
|
156
|
-
}[], tag: string, ctx:
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
declare abstract class ServerFilter {
|
|
160
|
-
constructor();
|
|
161
|
-
abstract use<E extends Exception>(error: Error | E, tag?: string, ctx?: ServerCtx): ServerErr | Promise<ServerErr>;
|
|
166
|
+
}[], tag: string, ctx: C): Promise<any[]>;
|
|
162
167
|
}
|
|
163
168
|
|
|
164
169
|
declare function generateRPCCode(meta: P.Meta[]): string;
|
|
165
170
|
|
|
166
171
|
declare function generateHTTPCode(meta: P.Meta[]): string;
|
|
167
172
|
|
|
168
|
-
export { APP_SYMBOL, Arg, BadGatewayException, BadRequestException,
|
|
173
|
+
export { APP_SYMBOL, Arg, BadGatewayException, BadRequestException, BaseParam, Body, ConflictException, Context, Controller, Define, Delete, Dev, Event, Exception, ForbiddenException, FrameworkException, Get, Guard, Head, Header, Interceptor, InvalidInputException, MERGE_SYMBOL, META_SYMBOL, MODULE_SYMBOL, Middle, NotFoundException, P, PFilter, PGuard, PInterceptor, PPipe, Param, Patch, PayloadLargeException, Post, Put, Query, Route, Rpc, SERIES_SYMBOL, ServiceUnavailableException, TimeoutException, UNMOUNT_SYMBOL, UnauthorizedException, UndefinedException, UnsupportedMediaTypeException, ValidateException, addGuard, addInterceptor, addMiddleware, defaultPipe, generateHTTPCode, generateRPCCode, guardsRecord, resolveDep, setFilter, setPipe };
|