@bool-ts/core 1.6.14 → 1.7.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.
Files changed (68) hide show
  1. package/.prettierrc +11 -11
  2. package/LICENSE +21 -21
  3. package/__test/controller.ts +93 -79
  4. package/__test/dispatcher.ts +16 -0
  5. package/__test/firstGuard.ts +10 -10
  6. package/__test/firstMiddleware.ts +15 -9
  7. package/__test/index.ts +8 -8
  8. package/__test/interfaces.ts +7 -7
  9. package/__test/module.ts +28 -30
  10. package/__test/repository.ts +16 -16
  11. package/__test/secondGuard.ts +10 -10
  12. package/__test/secondMiddleware.ts +15 -9
  13. package/__test/service.ts +20 -20
  14. package/bun.lockb +0 -0
  15. package/dist/decorators/arguments.d.ts +3 -3
  16. package/dist/decorators/arguments.js +3 -3
  17. package/dist/decorators/dispatcher.js +0 -3
  18. package/dist/decorators/index.d.ts +1 -1
  19. package/dist/decorators/index.js +1 -1
  20. package/dist/decorators/middleware.js +0 -3
  21. package/dist/decorators/module.d.ts +2 -4
  22. package/dist/decorators/module.js +5 -12
  23. package/dist/hooks/factory.d.ts +41 -2
  24. package/dist/hooks/factory.js +496 -404
  25. package/dist/hooks/injector.d.ts +14 -1
  26. package/dist/hooks/injector.js +3 -3
  27. package/dist/http/index.d.ts +1 -1
  28. package/dist/http/index.js +2 -1
  29. package/dist/interfaces/dispatcher.d.ts +3 -2
  30. package/dist/interfaces/middleware.d.ts +3 -2
  31. package/dist/keys/index.d.ts +2 -1
  32. package/dist/keys/index.js +2 -1
  33. package/jsconfig.json +27 -27
  34. package/package.json +3 -3
  35. package/src/decorators/arguments.ts +286 -286
  36. package/src/decorators/controller.ts +21 -21
  37. package/src/decorators/dispatcher.ts +14 -18
  38. package/src/decorators/guard.ts +18 -18
  39. package/src/decorators/http.ts +81 -81
  40. package/src/decorators/index.ts +29 -29
  41. package/src/decorators/inject.ts +13 -13
  42. package/src/decorators/injectable.ts +8 -8
  43. package/src/decorators/middleware.ts +14 -18
  44. package/src/decorators/module.ts +84 -94
  45. package/src/decorators/zodSchema.ts +19 -19
  46. package/src/entities/index.ts +5 -5
  47. package/src/entities/route.ts +327 -327
  48. package/src/entities/router.ts +35 -35
  49. package/src/entities/routerGroup.ts +34 -34
  50. package/src/hooks/factory.ts +990 -809
  51. package/src/hooks/index.ts +2 -2
  52. package/src/hooks/injector.ts +57 -57
  53. package/src/http/clientError.ts +45 -45
  54. package/src/http/index.ts +62 -61
  55. package/src/http/serverError.ts +27 -27
  56. package/src/index.ts +9 -9
  57. package/src/interfaces/context.ts +4 -4
  58. package/src/interfaces/controller.ts +1 -1
  59. package/src/interfaces/dispatcher.ts +4 -3
  60. package/src/interfaces/guard.ts +3 -3
  61. package/src/interfaces/index.ts +6 -6
  62. package/src/interfaces/middleware.ts +4 -3
  63. package/src/interfaces/module.ts +1 -1
  64. package/src/keys/index.ts +23 -22
  65. package/test.http +31 -31
  66. package/tsconfig.json +108 -108
  67. package/__test/afterDispatcher.ts +0 -9
  68. package/__test/beforeDispatcher.ts +0 -9
@@ -1,35 +1,35 @@
1
- "use strict";
2
-
3
- import Route from "./route";
4
-
5
- export class Router {
6
- public readonly alias: string;
7
-
8
- private _routes: Map<string, Route> = new Map();
9
-
10
- constructor(alias: string) {
11
- this.alias = this._thinAlias(alias);
12
- }
13
-
14
- public route(alias: string) {
15
- const thinAlias = this._thinAlias(`${this.alias}/${alias}`);
16
- const route = this._routes.get(thinAlias);
17
- const newRoute = !route ? new Route(`${this.alias}/${alias}`) : route;
18
-
19
- if (!route) {
20
- this._routes.set(thinAlias, newRoute);
21
- }
22
-
23
- return newRoute;
24
- }
25
-
26
- private _thinAlias(alias: string) {
27
- return alias.replace(new RegExp("[/]{2,}", "g"), "/").replace(new RegExp("^[/]|[/]$", "g"), "");
28
- }
29
-
30
- get routes() {
31
- return this._routes;
32
- }
33
- }
34
-
35
- export default Router;
1
+ "use strict";
2
+
3
+ import Route from "./route";
4
+
5
+ export class Router {
6
+ public readonly alias: string;
7
+
8
+ private _routes: Map<string, Route> = new Map();
9
+
10
+ constructor(alias: string) {
11
+ this.alias = this._thinAlias(alias);
12
+ }
13
+
14
+ public route(alias: string) {
15
+ const thinAlias = this._thinAlias(`${this.alias}/${alias}`);
16
+ const route = this._routes.get(thinAlias);
17
+ const newRoute = !route ? new Route(`${this.alias}/${alias}`) : route;
18
+
19
+ if (!route) {
20
+ this._routes.set(thinAlias, newRoute);
21
+ }
22
+
23
+ return newRoute;
24
+ }
25
+
26
+ private _thinAlias(alias: string) {
27
+ return alias.replace(new RegExp("[/]{2,}", "g"), "/").replace(new RegExp("^[/]|[/]$", "g"), "");
28
+ }
29
+
30
+ get routes() {
31
+ return this._routes;
32
+ }
33
+ }
34
+
35
+ export default Router;
@@ -1,34 +1,34 @@
1
- import type { THttpMethods } from "../http";
2
- import type { Router } from "./router";
3
-
4
- export class RouterGroup {
5
- private _routers: Map<string, Router> = new Map();
6
-
7
- public add(...routers: Array<Router>) {
8
- for (let i = 0; i < routers.length; i++) {
9
- if (this._routers.has(routers[i].alias)) {
10
- continue;
11
- }
12
-
13
- this._routers.set(routers[i].alias, routers[i]);
14
- }
15
-
16
- return this;
17
- }
18
-
19
- public find(pathame: string, method: keyof THttpMethods) {
20
- for (const router of [...this._routers.values()]) {
21
- for (const route of router.routes.values()) {
22
- const result = route.test(pathame, method);
23
-
24
- if (!result) {
25
- continue;
26
- }
27
-
28
- return result;
29
- }
30
- }
31
-
32
- return undefined;
33
- }
34
- }
1
+ import type { THttpMethods } from "../http";
2
+ import type { Router } from "./router";
3
+
4
+ export class RouterGroup {
5
+ private _routers: Map<string, Router> = new Map();
6
+
7
+ public add(...routers: Array<Router>) {
8
+ for (let i = 0; i < routers.length; i++) {
9
+ if (this._routers.has(routers[i].alias)) {
10
+ continue;
11
+ }
12
+
13
+ this._routers.set(routers[i].alias, routers[i]);
14
+ }
15
+
16
+ return this;
17
+ }
18
+
19
+ public find(pathame: string, method: keyof THttpMethods) {
20
+ for (const router of [...this._routers.values()]) {
21
+ for (const route of router.routes.values()) {
22
+ const result = route.test(pathame, method);
23
+
24
+ if (!result) {
25
+ continue;
26
+ }
27
+
28
+ return result;
29
+ }
30
+ }
31
+
32
+ return undefined;
33
+ }
34
+ }