@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.
- package/.prettierrc +11 -11
- package/LICENSE +21 -21
- package/__test/controller.ts +93 -79
- package/__test/dispatcher.ts +16 -0
- package/__test/firstGuard.ts +10 -10
- package/__test/firstMiddleware.ts +15 -9
- package/__test/index.ts +8 -8
- package/__test/interfaces.ts +7 -7
- package/__test/module.ts +28 -30
- package/__test/repository.ts +16 -16
- package/__test/secondGuard.ts +10 -10
- package/__test/secondMiddleware.ts +15 -9
- package/__test/service.ts +20 -20
- package/bun.lockb +0 -0
- package/dist/decorators/arguments.d.ts +3 -3
- package/dist/decorators/arguments.js +3 -3
- package/dist/decorators/dispatcher.js +0 -3
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/decorators/middleware.js +0 -3
- package/dist/decorators/module.d.ts +2 -4
- package/dist/decorators/module.js +5 -12
- package/dist/hooks/factory.d.ts +41 -2
- package/dist/hooks/factory.js +496 -404
- package/dist/hooks/injector.d.ts +14 -1
- package/dist/hooks/injector.js +3 -3
- package/dist/http/index.d.ts +1 -1
- package/dist/http/index.js +2 -1
- package/dist/interfaces/dispatcher.d.ts +3 -2
- package/dist/interfaces/middleware.d.ts +3 -2
- package/dist/keys/index.d.ts +2 -1
- package/dist/keys/index.js +2 -1
- package/jsconfig.json +27 -27
- package/package.json +3 -3
- package/src/decorators/arguments.ts +286 -286
- package/src/decorators/controller.ts +21 -21
- package/src/decorators/dispatcher.ts +14 -18
- package/src/decorators/guard.ts +18 -18
- package/src/decorators/http.ts +81 -81
- package/src/decorators/index.ts +29 -29
- package/src/decorators/inject.ts +13 -13
- package/src/decorators/injectable.ts +8 -8
- package/src/decorators/middleware.ts +14 -18
- package/src/decorators/module.ts +84 -94
- package/src/decorators/zodSchema.ts +19 -19
- package/src/entities/index.ts +5 -5
- package/src/entities/route.ts +327 -327
- package/src/entities/router.ts +35 -35
- package/src/entities/routerGroup.ts +34 -34
- package/src/hooks/factory.ts +990 -809
- package/src/hooks/index.ts +2 -2
- package/src/hooks/injector.ts +57 -57
- package/src/http/clientError.ts +45 -45
- package/src/http/index.ts +62 -61
- package/src/http/serverError.ts +27 -27
- package/src/index.ts +9 -9
- package/src/interfaces/context.ts +4 -4
- package/src/interfaces/controller.ts +1 -1
- package/src/interfaces/dispatcher.ts +4 -3
- package/src/interfaces/guard.ts +3 -3
- package/src/interfaces/index.ts +6 -6
- package/src/interfaces/middleware.ts +4 -3
- package/src/interfaces/module.ts +1 -1
- package/src/keys/index.ts +23 -22
- package/test.http +31 -31
- package/tsconfig.json +108 -108
- package/__test/afterDispatcher.ts +0 -9
- package/__test/beforeDispatcher.ts +0 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { controllerKey, dispatcherKey, guardKey, injectableKey, middlewareKey, moduleKey } from "../keys";
|
|
2
2
|
export const Module = (args) => (target) => {
|
|
3
|
-
const { middlewares, guards,
|
|
3
|
+
const { middlewares, guards, dispatchers, controllers, dependencies } = args || {};
|
|
4
4
|
if (middlewares) {
|
|
5
5
|
for (let i = 0; i < middlewares.length; i++) {
|
|
6
6
|
if (!Reflect.getOwnMetadataKeys(middlewares[i]).includes(middlewareKey)) {
|
|
@@ -15,10 +15,10 @@ export const Module = (args) => (target) => {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
if (
|
|
19
|
-
for (let i = 0; i <
|
|
20
|
-
if (!Reflect.getOwnMetadataKeys(
|
|
21
|
-
throw Error(`${
|
|
18
|
+
if (dispatchers) {
|
|
19
|
+
for (let i = 0; i < dispatchers.length; i++) {
|
|
20
|
+
if (!Reflect.getOwnMetadataKeys(dispatchers[i]).includes(dispatcherKey)) {
|
|
21
|
+
throw Error(`${dispatchers[i].name} is not a dispatcher.`);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -29,13 +29,6 @@ export const Module = (args) => (target) => {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
if (afterDispatchers) {
|
|
33
|
-
for (let i = 0; i < afterDispatchers.length; i++) {
|
|
34
|
-
if (!Reflect.getOwnMetadataKeys(afterDispatchers[i]).includes(dispatcherKey)) {
|
|
35
|
-
throw Error(`${afterDispatchers[i].name} is not a dispatcher.`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
32
|
if (dependencies) {
|
|
40
33
|
for (let i = 0; i < dependencies.length; i++) {
|
|
41
34
|
if (!Reflect.getOwnMetadataKeys(dependencies[i]).includes(injectableKey)) {
|
package/dist/hooks/factory.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import type { IMiddleware } from "../interfaces";
|
|
2
|
+
import type { IDispatcher } from "../interfaces/dispatcher";
|
|
1
3
|
import "colors";
|
|
2
4
|
import "reflect-metadata";
|
|
3
5
|
import Qs from "qs";
|
|
4
6
|
import * as Zod from "zod";
|
|
5
7
|
import { RouterGroup } from "../entities";
|
|
8
|
+
import { Injector } from "./injector";
|
|
9
|
+
export type TGroupElementModel<TFuncName extends keyof TClass, TClass extends Object = Object, TFunc = TClass[TFuncName]> = Readonly<{
|
|
10
|
+
class: TClass;
|
|
11
|
+
func: TFunc;
|
|
12
|
+
funcName: TFuncName;
|
|
13
|
+
}>;
|
|
6
14
|
export type TBoolFactoryOptions = Required<{
|
|
7
15
|
port: number;
|
|
8
16
|
}> & Partial<{
|
|
@@ -14,7 +22,38 @@ export type TBoolFactoryOptions = Required<{
|
|
|
14
22
|
}>;
|
|
15
23
|
queryParser: Parameters<typeof Qs.parse>[1];
|
|
16
24
|
}>;
|
|
17
|
-
export declare const
|
|
25
|
+
export declare const responseConverter: (response: Response) => Response;
|
|
26
|
+
export declare const controllerCreator: (controllerConstructor: new (...args: any[]) => unknown, group: RouterGroup, injector: Injector, prefix?: string) => RouterGroup;
|
|
18
27
|
export declare const argumentsResolution: (data: unknown, zodSchema: Zod.Schema, argumentIndex: number, funcName: string | symbol) => Promise<any>;
|
|
19
|
-
export declare const
|
|
28
|
+
export declare const moduleResolution: (module: new (...args: any[]) => unknown, options: TBoolFactoryOptions) => Promise<Readonly<{
|
|
29
|
+
prefix: string | undefined;
|
|
30
|
+
injector: Injector;
|
|
31
|
+
startMiddlewareGroup: Readonly<{
|
|
32
|
+
class: IMiddleware<any, any>;
|
|
33
|
+
func: (...args: any[]) => any;
|
|
34
|
+
funcName: "start";
|
|
35
|
+
}>[];
|
|
36
|
+
endMiddlewareGroup: Readonly<{
|
|
37
|
+
class: IMiddleware<any, any>;
|
|
38
|
+
func: (...args: any[]) => any;
|
|
39
|
+
funcName: "end";
|
|
40
|
+
}>[];
|
|
41
|
+
guardGroup: Readonly<{
|
|
42
|
+
class: new (...args: any[]) => any;
|
|
43
|
+
funcName: "enforce";
|
|
44
|
+
func: any;
|
|
45
|
+
}>[];
|
|
46
|
+
openDispatcherGroup: Readonly<{
|
|
47
|
+
class: IDispatcher<any, any>;
|
|
48
|
+
func: (...args: any[]) => any;
|
|
49
|
+
funcName: "open";
|
|
50
|
+
}>[];
|
|
51
|
+
closeDispatcherGroup: Readonly<{
|
|
52
|
+
class: IDispatcher<any, any>;
|
|
53
|
+
func: (...args: any[]) => any;
|
|
54
|
+
funcName: "close";
|
|
55
|
+
}>[];
|
|
56
|
+
routerGroup: RouterGroup;
|
|
57
|
+
}> | undefined>;
|
|
58
|
+
export declare const BoolFactory: (modules: new (...args: any[]) => unknown | Array<new (...args: any[]) => unknown>, options: TBoolFactoryOptions) => Promise<void>;
|
|
20
59
|
export default BoolFactory;
|