@bool-ts/core 1.9.28 → 2.0.0
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/decorators/arguments.d.ts +19 -20
- package/dist/decorators/container.d.ts +10 -11
- package/dist/decorators/http.d.ts +11 -11
- package/dist/decorators/index.d.ts +1 -2
- package/dist/entities/application.d.ts +111 -0
- package/dist/entities/context.d.ts +14 -0
- package/dist/entities/httpRoute.d.ts +18 -9
- package/dist/entities/httpRouter.d.ts +13 -0
- package/dist/entities/httpRouterGroup.d.ts +6 -0
- package/dist/entities/index.d.ts +2 -0
- package/dist/entities/injector.d.ts +29 -0
- package/dist/entities/validationFailed.d.ts +5 -0
- package/dist/entities/webSocketRoute.d.ts +1 -0
- package/dist/entities/webSocketRouter.d.ts +1 -0
- package/dist/entities/webSocketRouterGroup.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +22 -21
- package/dist/interfaces/customValidator.d.ts +4 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/producers/factory.d.ts +3 -1
- package/dist/producers/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/decorators/arguments.ts +44 -39
- package/src/decorators/container.ts +12 -12
- package/src/decorators/http.ts +8 -8
- package/src/decorators/index.ts +1 -2
- package/src/entities/application.ts +2236 -0
- package/src/{producers → entities}/context.ts +2 -0
- package/src/entities/httpRoute.ts +18 -9
- package/src/entities/httpRouter.ts +13 -0
- package/src/entities/httpRouterGroup.ts +10 -4
- package/src/entities/index.ts +2 -0
- package/src/entities/validationFailed.ts +5 -0
- package/src/entities/webSocketRoute.ts +2 -0
- package/src/entities/webSocketRouter.ts +2 -0
- package/src/entities/webSocketRouterGroup.ts +2 -0
- package/src/index.ts +1 -0
- package/src/interfaces/customValidator.ts +10 -0
- package/src/interfaces/index.ts +1 -0
- package/src/producers/factory.ts +7 -2037
- package/src/producers/index.ts +1 -1
- package/src/decorators/zodSchema.ts +0 -21
- /package/src/{producers → entities}/injector.ts +0 -0
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import * as Zod from "zod";
|
|
2
1
|
import { contextArgsKey, httpServerArgsKey, paramArgsKey, paramsArgsKey, queryArgsKey, requestArgsKey, requestBodyArgsKey, requestHeaderArgsKey, requestHeadersArgsKey, responseHeadersArgsKey, routeModelArgsKey } from "../keys";
|
|
3
|
-
export type TArgumentsMetadata = {
|
|
2
|
+
export type TArgumentsMetadata<TValidationSchema = unknown> = {
|
|
4
3
|
index: number;
|
|
5
4
|
type: typeof requestHeadersArgsKey;
|
|
6
|
-
|
|
5
|
+
validationSchema?: TValidationSchema;
|
|
7
6
|
} | {
|
|
8
7
|
index: number;
|
|
9
8
|
type: typeof requestHeaderArgsKey;
|
|
10
9
|
key: string;
|
|
11
|
-
|
|
10
|
+
validationSchema?: TValidationSchema;
|
|
12
11
|
} | {
|
|
13
12
|
index: number;
|
|
14
13
|
type: typeof requestBodyArgsKey;
|
|
15
|
-
|
|
14
|
+
validationSchema?: TValidationSchema;
|
|
16
15
|
parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
|
|
17
16
|
} | {
|
|
18
17
|
index: number;
|
|
19
18
|
type: typeof paramsArgsKey;
|
|
20
|
-
|
|
19
|
+
validationSchema?: TValidationSchema;
|
|
21
20
|
} | {
|
|
22
21
|
index: number;
|
|
23
22
|
type: typeof paramArgsKey;
|
|
24
23
|
key: string;
|
|
25
|
-
|
|
24
|
+
validationSchema?: TValidationSchema;
|
|
26
25
|
} | {
|
|
27
26
|
index: number;
|
|
28
27
|
type: typeof queryArgsKey;
|
|
29
|
-
|
|
28
|
+
validationSchema?: TValidationSchema;
|
|
30
29
|
} | {
|
|
31
30
|
index: number;
|
|
32
31
|
type: typeof requestArgsKey;
|
|
33
|
-
|
|
32
|
+
validationSchema?: TValidationSchema;
|
|
34
33
|
} | {
|
|
35
34
|
index: number;
|
|
36
35
|
type: typeof responseHeadersArgsKey;
|
|
@@ -46,14 +45,14 @@ export type TArgumentsMetadata = {
|
|
|
46
45
|
type: typeof httpServerArgsKey;
|
|
47
46
|
};
|
|
48
47
|
export type TArgumentsMetadataCollection = Record<`argumentIndexes.${number}`, TArgumentsMetadata>;
|
|
49
|
-
export declare const RequestHeaders: <
|
|
50
|
-
export declare const RequestHeader: <
|
|
51
|
-
export declare const RequestBody: <
|
|
52
|
-
export declare const Params: <
|
|
53
|
-
export declare const Param: <
|
|
54
|
-
export declare const Query: <
|
|
55
|
-
export declare const Request: <
|
|
56
|
-
export declare const ResponseHeaders: <
|
|
57
|
-
export declare const Context: <
|
|
58
|
-
export declare const RouteModel: <
|
|
59
|
-
export declare const HttpServer: <
|
|
48
|
+
export declare const RequestHeaders: <TTarget extends Object, TValidationSchema = unknown>(validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
49
|
+
export declare const RequestHeader: <TTarget extends Object, TValidationSchema = unknown>(key: string, validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
50
|
+
export declare const RequestBody: <TTarget extends Object, TValidationSchema = unknown>(validationSchema?: TValidationSchema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
51
|
+
export declare const Params: <TTarget extends Object, TValidationSchema = unknown>(validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
52
|
+
export declare const Param: <TTarget extends Object, TValidationSchema = unknown>(key: string, validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
53
|
+
export declare const Query: <TTarget extends Object, TValidationSchema = unknown>(validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
54
|
+
export declare const Request: <TTarget extends Object, TValidationSchema = unknown>(validationSchema?: TValidationSchema) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
55
|
+
export declare const ResponseHeaders: <TTarget extends Object>() => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
56
|
+
export declare const Context: <TTarget extends Object>(key?: symbol) => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
57
|
+
export declare const RouteModel: <TTarget extends Object>() => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
58
|
+
export declare const HttpServer: <TTarget extends Object>() => (target: TTarget, methodName: string | symbol | undefined, parameterIndex: number) => void;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { TConstructor } from "../ultils";
|
|
2
|
-
type TInstances = Array<new (...args: any[]) => any>;
|
|
3
2
|
type TLoaders<TConfig extends {} = {}> = Record<string | symbol, (args: {
|
|
4
3
|
config: TConfig;
|
|
5
4
|
}) => [string | symbol, any] | Promise<[string | symbol, any]>>;
|
|
@@ -8,20 +7,20 @@ export type TContainerConfig<TConfig> = TConfig | (() => TConfig | Promise<TConf
|
|
|
8
7
|
value: TConfig | (() => TConfig | Promise<TConfig>);
|
|
9
8
|
}>;
|
|
10
9
|
export type TContainerOptions<TConfig extends {} = {}> = Partial<{
|
|
11
|
-
config: TContainerConfig<TConfig>;
|
|
12
|
-
modules: TInstances;
|
|
13
|
-
dependencies: TInstances;
|
|
14
10
|
loaders: TLoaders<TConfig>;
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
config: TContainerConfig<TConfig>;
|
|
12
|
+
modules: Array<TConstructor<unknown>>;
|
|
13
|
+
dependencies: Array<TConstructor<unknown>>;
|
|
14
|
+
middlewares: Array<TConstructor<unknown>>;
|
|
15
|
+
guards: Array<TConstructor<unknown>>;
|
|
17
16
|
}> | undefined;
|
|
18
17
|
export type TContainerMetadata<TConfig extends {} = {}> = Partial<{
|
|
19
|
-
modules: TInstances;
|
|
20
|
-
config: TContainerConfig<TConfig>;
|
|
21
|
-
dependencies: TInstances;
|
|
22
18
|
loaders: TLoaders<TConfig>;
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
config: TContainerConfig<TConfig>;
|
|
20
|
+
modules: Array<TConstructor<unknown>>;
|
|
21
|
+
dependencies: Array<TConstructor<unknown>>;
|
|
22
|
+
middlewares: Array<TConstructor<unknown>>;
|
|
23
|
+
guards: Array<TConstructor<unknown>>;
|
|
25
24
|
}> | undefined;
|
|
26
25
|
export declare const Container: <TConfig extends {} = {}, K extends TConstructor<Object> = TConstructor<Object>>(args?: TContainerOptions<TConfig>) => (target: K) => void;
|
|
27
26
|
export default Container;
|
|
@@ -12,42 +12,42 @@ export type THttpMetadata = Array<TRoute>;
|
|
|
12
12
|
* @param path
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
|
-
export declare const Get: <T
|
|
15
|
+
export declare const Get: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
18
18
|
* @param path
|
|
19
19
|
* @returns
|
|
20
20
|
*/
|
|
21
|
-
export declare const Post: <T
|
|
21
|
+
export declare const Post: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
24
|
* @param path
|
|
25
25
|
* @returns
|
|
26
26
|
*/
|
|
27
|
-
export declare const Put: <T
|
|
27
|
+
export declare const Put: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
28
28
|
/**
|
|
29
29
|
*
|
|
30
30
|
* @param path
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
export declare const Patch: <T
|
|
33
|
+
export declare const Patch: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
34
34
|
/**
|
|
35
35
|
*
|
|
36
36
|
* @param path
|
|
37
37
|
* @returns
|
|
38
38
|
*/
|
|
39
|
-
export declare const Delete: <T
|
|
39
|
+
export declare const Delete: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
40
40
|
/**
|
|
41
41
|
*
|
|
42
42
|
* @param path
|
|
43
43
|
* @returns
|
|
44
44
|
*/
|
|
45
|
-
export declare const Options: <T
|
|
45
|
+
export declare const Options: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
46
46
|
declare const _default: {
|
|
47
|
-
Get: <T
|
|
48
|
-
Post: <T
|
|
49
|
-
Put: <T
|
|
50
|
-
Patch: <T
|
|
51
|
-
Delete: <T
|
|
47
|
+
Get: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
48
|
+
Post: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
49
|
+
Put: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
50
|
+
Patch: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
51
|
+
Delete: <T extends Object, K>(path?: string) => (target: T, methodName: string | symbol, descriptor: TypedPropertyDescriptor<K>) => void;
|
|
52
52
|
};
|
|
53
53
|
export default _default;
|
|
@@ -11,8 +11,7 @@ export { Module } from "./module";
|
|
|
11
11
|
export { WebSocket } from "./webSocket";
|
|
12
12
|
export { WebSocketCloseCode, WebSocketCloseReason, WebSocketConnection, WebSocketMessage, WebSocketServer } from "./webSocketArguments";
|
|
13
13
|
export { WebSocketEvent } from "./webSocketEvent";
|
|
14
|
-
export {
|
|
15
|
-
export type { TArgumentsMetadata } from "./arguments";
|
|
14
|
+
export type { TArgumentsMetadata, TArgumentsMetadataCollection } from "./arguments";
|
|
16
15
|
export type { TContainerConfig, TContainerMetadata, TContainerOptions } from "./container";
|
|
17
16
|
export type { TControllerMetadata } from "./controller";
|
|
18
17
|
export type { TGuardMetadata } from "./guard";
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { TContainerMetadata, TWebSocketEventHandlerMetadata } from "../decorators";
|
|
2
|
+
import type { TConstructor } from "../ultils";
|
|
3
|
+
import { parse as QsParse } from "qs";
|
|
4
|
+
import type { ICustomValidator } from "../interfaces/customValidator";
|
|
5
|
+
type TParamsType = Record<string, string>;
|
|
6
|
+
type TApplicationOptions = Required<{
|
|
7
|
+
port: number;
|
|
8
|
+
}> & Partial<{
|
|
9
|
+
config: Record<string | symbol, any> | (() => Record<string | symbol, any>);
|
|
10
|
+
prefix: string;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
log: Partial<{
|
|
13
|
+
methods: Array<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS">;
|
|
14
|
+
}>;
|
|
15
|
+
queryParser: Parameters<typeof QsParse>[1];
|
|
16
|
+
static: Required<{
|
|
17
|
+
path: string;
|
|
18
|
+
}> & Partial<{
|
|
19
|
+
headers: TParamsType;
|
|
20
|
+
cacheTimeInSeconds: number;
|
|
21
|
+
}>;
|
|
22
|
+
cors: Partial<{
|
|
23
|
+
credentials: boolean;
|
|
24
|
+
origins: string | Array<string>;
|
|
25
|
+
methods: Array<"GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS">;
|
|
26
|
+
headers: Array<string>;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
type TPreLaunch = undefined | Readonly<{
|
|
30
|
+
containerMetadata: TContainerMetadata;
|
|
31
|
+
modulesConverted: Array<TConstructor<unknown>>;
|
|
32
|
+
resolutedContainer?: Awaited<ReturnType<Application["containerResolution"]>>;
|
|
33
|
+
resolutedModules: Array<Awaited<ReturnType<Application["moduleResolution"]>>>;
|
|
34
|
+
webSocketsMap: Map<string, TWebSocketEventHandlerMetadata>;
|
|
35
|
+
}>;
|
|
36
|
+
export declare class Application<TRootClass extends Object = Object> {
|
|
37
|
+
#private;
|
|
38
|
+
private readonly classConstructor;
|
|
39
|
+
private readonly options;
|
|
40
|
+
constructor(classConstructor: TConstructor<TRootClass>, options: TApplicationOptions);
|
|
41
|
+
useValidator(validator: ICustomValidator): void;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @returns
|
|
45
|
+
*/
|
|
46
|
+
preLaunch(): Promise<NonNullable<TPreLaunch>>;
|
|
47
|
+
/**
|
|
48
|
+
* Start listen app on a port
|
|
49
|
+
* @param port
|
|
50
|
+
*/
|
|
51
|
+
listen(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param param0
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
private containerResolution;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param param0
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
private moduleResolution;
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param data
|
|
67
|
+
* @param zodSchema
|
|
68
|
+
* @param argumentIndex
|
|
69
|
+
* @param funcName
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
private argumentsResolution;
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param param0
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
private initControllerInstance;
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param param0
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
private initWebSocketInstance;
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param param0
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
private serializeResponse;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* @param response
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
private finalizeResponse;
|
|
97
|
+
/**
|
|
98
|
+
*
|
|
99
|
+
* @param param0
|
|
100
|
+
* @returns
|
|
101
|
+
*/
|
|
102
|
+
private httpFetcher;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @param bun
|
|
106
|
+
* @param bool
|
|
107
|
+
* @returns
|
|
108
|
+
*/
|
|
109
|
+
private webSocketFetcher;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IContext, TContextOptions } from "../interfaces";
|
|
2
|
+
export declare class Context implements IContext {
|
|
3
|
+
private readonly _staticMap;
|
|
4
|
+
private readonly _dynamicMap;
|
|
5
|
+
private _options?;
|
|
6
|
+
constructor(...contexts: Array<Context>);
|
|
7
|
+
get<T = unknown>(key: symbol, options?: TContextOptions): T;
|
|
8
|
+
has(key: symbol, options?: TContextOptions): boolean;
|
|
9
|
+
set(key: symbol, value: any, options?: TContextOptions): this;
|
|
10
|
+
setOptions(options: TContextOptions): this;
|
|
11
|
+
get staticEntries(): [symbol, any][];
|
|
12
|
+
get dynamicEntries(): [symbol, any][];
|
|
13
|
+
}
|
|
14
|
+
export default Context;
|
|
@@ -12,41 +12,50 @@ export declare class HttpRoute {
|
|
|
12
12
|
readonly alias: string;
|
|
13
13
|
private _map;
|
|
14
14
|
constructor(alias: string);
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param pathname
|
|
18
|
+
* @param method
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
15
21
|
test(pathname: string, method: keyof THttpMethods): Readonly<{
|
|
16
22
|
parameters: Record<string, string>;
|
|
17
23
|
model: THttpRouteModel;
|
|
18
24
|
}> | false | undefined;
|
|
19
25
|
/**
|
|
20
26
|
*
|
|
27
|
+
* @param pathname
|
|
28
|
+
* @param method
|
|
29
|
+
* @returns
|
|
21
30
|
*/
|
|
22
31
|
isMatch(pathname: string, method: keyof THttpMethods): boolean | undefined;
|
|
23
32
|
/**
|
|
24
33
|
*
|
|
25
|
-
* @param
|
|
34
|
+
* @param handler
|
|
26
35
|
* @returns
|
|
27
36
|
*/
|
|
28
37
|
get(handler: THttpRouteModel): this;
|
|
29
38
|
/**
|
|
30
39
|
*
|
|
31
|
-
* @param
|
|
40
|
+
* @param handler
|
|
32
41
|
* @returns
|
|
33
42
|
*/
|
|
34
43
|
post(handler: THttpRouteModel): this;
|
|
35
44
|
/**
|
|
36
45
|
*
|
|
37
|
-
* @param
|
|
46
|
+
* @param handler
|
|
38
47
|
* @returns
|
|
39
48
|
*/
|
|
40
49
|
put(handler: THttpRouteModel): this;
|
|
41
50
|
/**
|
|
42
51
|
*
|
|
43
|
-
* @param
|
|
52
|
+
* @param handler
|
|
44
53
|
* @returns
|
|
45
54
|
*/
|
|
46
55
|
delete(handler: THttpRouteModel): this;
|
|
47
56
|
/**
|
|
48
57
|
*
|
|
49
|
-
* @param
|
|
58
|
+
* @param handler
|
|
50
59
|
* @returns
|
|
51
60
|
*/
|
|
52
61
|
connect(handler: THttpRouteModel): this | Map<keyof THttpMethods, Readonly<{
|
|
@@ -57,7 +66,7 @@ export declare class HttpRoute {
|
|
|
57
66
|
}>>;
|
|
58
67
|
/**
|
|
59
68
|
*
|
|
60
|
-
* @param
|
|
69
|
+
* @param handler
|
|
61
70
|
* @returns
|
|
62
71
|
*/
|
|
63
72
|
options(handler: THttpRouteModel): this | Map<keyof THttpMethods, Readonly<{
|
|
@@ -68,7 +77,7 @@ export declare class HttpRoute {
|
|
|
68
77
|
}>>;
|
|
69
78
|
/**
|
|
70
79
|
*
|
|
71
|
-
* @param
|
|
80
|
+
* @param handler
|
|
72
81
|
* @returns
|
|
73
82
|
*/
|
|
74
83
|
trace(handler: THttpRouteModel): this | Map<keyof THttpMethods, Readonly<{
|
|
@@ -79,7 +88,7 @@ export declare class HttpRoute {
|
|
|
79
88
|
}>>;
|
|
80
89
|
/**
|
|
81
90
|
*
|
|
82
|
-
* @param
|
|
91
|
+
* @param handler
|
|
83
92
|
* @returns
|
|
84
93
|
*/
|
|
85
94
|
patch(handler: THttpRouteModel): this | Map<keyof THttpMethods, Readonly<{
|
|
@@ -90,7 +99,7 @@ export declare class HttpRoute {
|
|
|
90
99
|
}>>;
|
|
91
100
|
/**
|
|
92
101
|
*
|
|
93
|
-
* @param
|
|
102
|
+
* @param handler
|
|
94
103
|
* @returns
|
|
95
104
|
*/
|
|
96
105
|
private _thinAlias;
|
|
@@ -3,8 +3,21 @@ export declare class HttpRouter {
|
|
|
3
3
|
readonly alias: string;
|
|
4
4
|
private _routes;
|
|
5
5
|
constructor(alias: string);
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param alias
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
6
11
|
route(alias: string): HttpRoute;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param alias
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
7
17
|
private _thinAlias;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
8
21
|
get routes(): Map<string, HttpRoute>;
|
|
9
22
|
}
|
|
10
23
|
export default HttpRouter;
|
|
@@ -3,6 +3,12 @@ import type { HttpRouter } from "./httpRouter";
|
|
|
3
3
|
export declare class HttpRouterGroup {
|
|
4
4
|
private _routers;
|
|
5
5
|
add(...routers: Array<HttpRouter>): this;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param pathame
|
|
9
|
+
* @param method
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
6
12
|
find(pathame: string, method: keyof THttpMethods): Readonly<{
|
|
7
13
|
parameters: Record<string, string>;
|
|
8
14
|
model: import("./httpRoute").THttpRouteModel;
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type { THttpRouteModel } from "./httpRoute";
|
|
2
|
+
export { Application } from "./application";
|
|
2
3
|
export { HttpRoute } from "./httpRoute";
|
|
3
4
|
export { HttpRouter } from "./httpRouter";
|
|
4
5
|
export { HttpRouterGroup } from "./httpRouterGroup";
|
|
6
|
+
export { ValidationFailed } from "./validationFailed";
|
|
5
7
|
export { WebSocketRoute } from "./webSocketRoute";
|
|
6
8
|
export { WebSocketRouter } from "./webSocketRouter";
|
|
7
9
|
export { WebSocketRouterGroup } from "./webSocketRouterGroup";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
type TDefinition<T = any> = {
|
|
3
|
+
new (...args: any[]): T;
|
|
4
|
+
} | string | symbol;
|
|
5
|
+
interface IInjector {
|
|
6
|
+
set(key: TDefinition, value: any): void;
|
|
7
|
+
get<T>(definition: TDefinition): T;
|
|
8
|
+
}
|
|
9
|
+
export declare class Injector implements IInjector {
|
|
10
|
+
private readonly _mapper;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param injectors
|
|
14
|
+
*/
|
|
15
|
+
constructor(...injectors: Array<Injector>);
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param definition
|
|
19
|
+
*/
|
|
20
|
+
get<T>(definition: TDefinition): any;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param key
|
|
24
|
+
* @param value
|
|
25
|
+
*/
|
|
26
|
+
set(key: TDefinition, value: any): void;
|
|
27
|
+
get entries(): [string | symbol | Function, any][];
|
|
28
|
+
}
|
|
29
|
+
export default Injector;
|