@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
|
@@ -22,6 +22,12 @@ export class HttpRoute {
|
|
|
22
22
|
this.alias = this._thinAlias(alias);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param pathname
|
|
28
|
+
* @param method
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
25
31
|
public test(
|
|
26
32
|
pathname: string,
|
|
27
33
|
method: keyof THttpMethods
|
|
@@ -105,6 +111,9 @@ export class HttpRoute {
|
|
|
105
111
|
|
|
106
112
|
/**
|
|
107
113
|
*
|
|
114
|
+
* @param pathname
|
|
115
|
+
* @param method
|
|
116
|
+
* @returns
|
|
108
117
|
*/
|
|
109
118
|
public isMatch(pathname: string, method: keyof THttpMethods) {
|
|
110
119
|
try {
|
|
@@ -167,7 +176,7 @@ export class HttpRoute {
|
|
|
167
176
|
|
|
168
177
|
/**
|
|
169
178
|
*
|
|
170
|
-
* @param
|
|
179
|
+
* @param handler
|
|
171
180
|
* @returns
|
|
172
181
|
*/
|
|
173
182
|
public get(handler: THttpRouteModel) {
|
|
@@ -182,7 +191,7 @@ export class HttpRoute {
|
|
|
182
191
|
|
|
183
192
|
/**
|
|
184
193
|
*
|
|
185
|
-
* @param
|
|
194
|
+
* @param handler
|
|
186
195
|
* @returns
|
|
187
196
|
*/
|
|
188
197
|
public post(handler: THttpRouteModel) {
|
|
@@ -197,7 +206,7 @@ export class HttpRoute {
|
|
|
197
206
|
|
|
198
207
|
/**
|
|
199
208
|
*
|
|
200
|
-
* @param
|
|
209
|
+
* @param handler
|
|
201
210
|
* @returns
|
|
202
211
|
*/
|
|
203
212
|
public put(handler: THttpRouteModel) {
|
|
@@ -212,7 +221,7 @@ export class HttpRoute {
|
|
|
212
221
|
|
|
213
222
|
/**
|
|
214
223
|
*
|
|
215
|
-
* @param
|
|
224
|
+
* @param handler
|
|
216
225
|
* @returns
|
|
217
226
|
*/
|
|
218
227
|
public delete(handler: THttpRouteModel) {
|
|
@@ -227,7 +236,7 @@ export class HttpRoute {
|
|
|
227
236
|
|
|
228
237
|
/**
|
|
229
238
|
*
|
|
230
|
-
* @param
|
|
239
|
+
* @param handler
|
|
231
240
|
* @returns
|
|
232
241
|
*/
|
|
233
242
|
public connect(handler: THttpRouteModel) {
|
|
@@ -242,7 +251,7 @@ export class HttpRoute {
|
|
|
242
251
|
|
|
243
252
|
/**
|
|
244
253
|
*
|
|
245
|
-
* @param
|
|
254
|
+
* @param handler
|
|
246
255
|
* @returns
|
|
247
256
|
*/
|
|
248
257
|
public options(handler: THttpRouteModel) {
|
|
@@ -257,7 +266,7 @@ export class HttpRoute {
|
|
|
257
266
|
|
|
258
267
|
/**
|
|
259
268
|
*
|
|
260
|
-
* @param
|
|
269
|
+
* @param handler
|
|
261
270
|
* @returns
|
|
262
271
|
*/
|
|
263
272
|
public trace(handler: THttpRouteModel) {
|
|
@@ -272,7 +281,7 @@ export class HttpRoute {
|
|
|
272
281
|
|
|
273
282
|
/**
|
|
274
283
|
*
|
|
275
|
-
* @param
|
|
284
|
+
* @param handler
|
|
276
285
|
* @returns
|
|
277
286
|
*/
|
|
278
287
|
public patch(handler: THttpRouteModel) {
|
|
@@ -287,7 +296,7 @@ export class HttpRoute {
|
|
|
287
296
|
|
|
288
297
|
/**
|
|
289
298
|
*
|
|
290
|
-
* @param
|
|
299
|
+
* @param handler
|
|
291
300
|
* @returns
|
|
292
301
|
*/
|
|
293
302
|
private _thinAlias(alias: string) {
|
|
@@ -11,6 +11,11 @@ export class HttpRouter {
|
|
|
11
11
|
this.alias = this._thinAlias(alias);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param alias
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
14
19
|
public route(alias: string) {
|
|
15
20
|
const thinAlias = this._thinAlias(`${this.alias}/${alias}`);
|
|
16
21
|
const route = this._routes.get(thinAlias);
|
|
@@ -23,12 +28,20 @@ export class HttpRouter {
|
|
|
23
28
|
return newRoute;
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param alias
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
26
36
|
private _thinAlias(alias: string) {
|
|
27
37
|
return alias
|
|
28
38
|
.replace(new RegExp("[/]{2,}", "g"), "/")
|
|
29
39
|
.replace(new RegExp("^[/]|[/]$", "g"), "");
|
|
30
40
|
}
|
|
31
41
|
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
32
45
|
get routes() {
|
|
33
46
|
return this._routes;
|
|
34
47
|
}
|
|
@@ -5,19 +5,25 @@ export class HttpRouterGroup {
|
|
|
5
5
|
private _routers: Map<string, HttpRouter> = new Map();
|
|
6
6
|
|
|
7
7
|
public add(...routers: Array<HttpRouter>) {
|
|
8
|
-
for (
|
|
9
|
-
if (this._routers.has(
|
|
8
|
+
for (const router of routers) {
|
|
9
|
+
if (this._routers.has(router.alias)) {
|
|
10
10
|
continue;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
this._routers.set(
|
|
13
|
+
this._routers.set(router.alias, router);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
return this;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param pathame
|
|
22
|
+
* @param method
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
19
25
|
public find(pathame: string, method: keyof THttpMethods) {
|
|
20
|
-
for (const router of
|
|
26
|
+
for (const router of this._routers.values()) {
|
|
21
27
|
for (const route of router.routes.values()) {
|
|
22
28
|
const result = route.test(pathame, method);
|
|
23
29
|
|
package/src/entities/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export type { THttpRouteModel } from "./httpRoute";
|
|
2
2
|
|
|
3
|
+
export { Application } from "./application";
|
|
3
4
|
export { HttpRoute } from "./httpRoute";
|
|
4
5
|
export { HttpRouter } from "./httpRouter";
|
|
5
6
|
export { HttpRouterGroup } from "./httpRouterGroup";
|
|
7
|
+
export { ValidationFailed } from "./validationFailed";
|
|
6
8
|
export { WebSocketRoute } from "./webSocketRoute";
|
|
7
9
|
export { WebSocketRouter } from "./webSocketRouter";
|
|
8
10
|
export { WebSocketRouterGroup } from "./webSocketRouterGroup";
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ValidationFailed } from "../entities";
|
|
2
|
+
|
|
3
|
+
export interface ICustomValidator<TValidData = unknown, TValidationSchema = unknown> {
|
|
4
|
+
validate(
|
|
5
|
+
data: unknown,
|
|
6
|
+
validationSchema: TValidationSchema,
|
|
7
|
+
argumentIndex: number,
|
|
8
|
+
funcName: string | symbol
|
|
9
|
+
): (TValidData | ValidationFailed) | Promise<TValidData | ValidationFailed>;
|
|
10
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type { IContainer } from "./container";
|
|
2
2
|
export type { IContext, TContextOptions } from "./context";
|
|
3
3
|
export type { IController } from "./controller";
|
|
4
|
+
export type { ICustomValidator } from "./customValidator";
|
|
4
5
|
export type { IGuard } from "./guard";
|
|
5
6
|
export type { IInterceptor } from "./interceptor";
|
|
6
7
|
export type { IMiddleware } from "./middleware";
|