@bool-ts/core 1.3.2 → 1.4.1
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 -0
- package/LICENSE +21 -21
- package/__test/controller.ts +66 -79
- package/__test/index.ts +8 -11
- package/__test/interfaces.ts +7 -7
- package/__test/module.ts +16 -17
- package/__test/repository.ts +16 -16
- package/__test/service.ts +20 -20
- package/bun.lockb +0 -0
- package/dist/decorators/arguments.d.ts +43 -0
- package/dist/decorators/arguments.js +97 -0
- package/dist/decorators/controller.d.ts +2 -2
- package/dist/decorators/controller.js +6 -10
- package/dist/decorators/http.d.ts +1 -1
- package/dist/decorators/http.js +16 -103
- package/dist/decorators/index.d.ts +1 -0
- package/dist/decorators/index.js +7 -26
- package/dist/decorators/inject.js +5 -9
- package/dist/decorators/injectable.d.ts +2 -2
- package/dist/decorators/injectable.js +4 -8
- package/dist/decorators/module.d.ts +4 -2
- package/dist/decorators/module.js +4 -8
- package/dist/decorators/zodSchema.d.ts +1 -1
- package/dist/decorators/zodSchema.js +5 -8
- package/dist/entities/index.d.ts +3 -0
- package/dist/entities/index.js +3 -0
- package/dist/entities/route.d.ts +101 -0
- package/dist/entities/route.js +257 -0
- package/dist/entities/router.d.ts +10 -0
- package/dist/entities/router.js +25 -0
- package/dist/entities/routerGroup.d.ts +14 -0
- package/dist/entities/routerGroup.js +24 -0
- package/dist/hooks/factory.d.ts +12 -12
- package/dist/hooks/factory.js +202 -150
- package/dist/hooks/index.js +2 -7
- package/dist/hooks/injector.js +7 -10
- package/dist/http/clientError.d.ts +1 -1
- package/dist/http/clientError.js +3 -7
- package/dist/http/index.d.ts +12 -2
- package/dist/http/index.js +34 -73
- package/dist/http/serverError.js +3 -7
- package/dist/index.js +5 -21
- package/dist/interfaces/index.js +1 -3
- package/dist/ultils/asyncFunction.js +1 -4
- package/dist/ultils/index.js +1 -17
- package/package.json +30 -33
- package/src/decorators/arguments.ts +186 -0
- package/src/decorators/controller.ts +14 -18
- package/src/decorators/http.ts +81 -195
- package/src/decorators/index.ts +7 -6
- package/src/decorators/inject.ts +13 -19
- package/src/decorators/injectable.ts +11 -12
- package/src/decorators/module.ts +21 -22
- package/src/decorators/zodSchema.ts +20 -27
- package/src/entities/index.ts +3 -0
- package/src/entities/route.ts +328 -0
- package/src/entities/router.ts +35 -0
- package/src/entities/routerGroup.ts +34 -0
- package/src/hooks/factory.ts +319 -205
- package/src/hooks/index.ts +2 -2
- package/src/hooks/injector.ts +43 -43
- package/src/http/clientError.ts +45 -56
- package/src/http/index.ts +63 -72
- package/src/http/serverError.ts +38 -38
- package/src/index.ts +6 -6
- package/src/interfaces/index.ts +3 -3
- package/test.http +30 -28
- package/tsconfig.json +107 -109
package/dist/http/index.js
CHANGED
|
@@ -1,80 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { HttpClientError } from "./clientError";
|
|
2
|
+
import { HttpServerError } from "./serverError";
|
|
3
|
+
export const jsonErrorInfer = (data) => {
|
|
4
|
+
const headers = new Headers();
|
|
5
|
+
headers.append("Content-Type", "application/json");
|
|
6
|
+
if (data instanceof HttpClientError || data instanceof HttpServerError) {
|
|
7
|
+
return new Response(JSON.stringify(data), {
|
|
8
|
+
status: data.httpCode,
|
|
9
|
+
statusText: data.message,
|
|
10
|
+
headers: headers
|
|
11
|
+
});
|
|
7
12
|
}
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.errorInfer = void 0;
|
|
18
|
-
const clientError_1 = require("./clientError");
|
|
19
|
-
const serverError_1 = require("./serverError");
|
|
20
|
-
const errorInfer = (res, data) => {
|
|
21
|
-
if (res.headersSent) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
if (data instanceof clientError_1.HttpClientError) {
|
|
26
|
-
res.status(data.httpCode).json(data);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (data instanceof serverError_1.HttpServerError) {
|
|
30
|
-
res.status(data.httpCode).json(data);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
if (typeof data === "object") {
|
|
34
|
-
res.status(500).json({
|
|
35
|
-
httpCode: 500,
|
|
36
|
-
message: "INTERNAL SERVER ERROR",
|
|
37
|
-
data: !(data instanceof Error) ? data : {
|
|
38
|
-
message: data.message,
|
|
39
|
-
code: data.name,
|
|
40
|
-
cause: data.cause
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
13
|
+
return new Response(JSON.stringify((() => {
|
|
45
14
|
switch (typeof data) {
|
|
15
|
+
case "object":
|
|
16
|
+
return !(data instanceof Error)
|
|
17
|
+
? data
|
|
18
|
+
: {
|
|
19
|
+
message: data.message,
|
|
20
|
+
code: data.name,
|
|
21
|
+
cause: data.cause
|
|
22
|
+
};
|
|
46
23
|
case "string":
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
data: {
|
|
51
|
-
message: data
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return;
|
|
24
|
+
return {
|
|
25
|
+
message: data
|
|
26
|
+
};
|
|
55
27
|
case "number":
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
data: {
|
|
60
|
-
code: data
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
28
|
+
return {
|
|
29
|
+
code: data
|
|
30
|
+
};
|
|
64
31
|
default:
|
|
65
|
-
|
|
66
|
-
httpCode: 500,
|
|
67
|
-
message: "INTERNAL SERVER ERROR",
|
|
68
|
-
data: undefined
|
|
69
|
-
});
|
|
70
|
-
return;
|
|
32
|
+
return undefined;
|
|
71
33
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
34
|
+
})()), {
|
|
35
|
+
status: 500,
|
|
36
|
+
statusText: "INTERNAL SERVER ERROR",
|
|
37
|
+
headers: headers
|
|
38
|
+
});
|
|
77
39
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
__exportStar(require("./serverError"), exports);
|
|
40
|
+
export * from "./clientError";
|
|
41
|
+
export * from "./serverError";
|
package/dist/http/serverError.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpServerError = exports.httpServerErrors = void 0;
|
|
4
|
-
exports.httpServerErrors = Object.freeze({
|
|
1
|
+
export const httpServerErrors = Object.freeze({
|
|
5
2
|
500: "INTERNAL_SERVER_ERROR",
|
|
6
3
|
501: "NOT_IMPLEMENTED",
|
|
7
4
|
502: "BAD_GATEWAY",
|
|
@@ -14,15 +11,14 @@ exports.httpServerErrors = Object.freeze({
|
|
|
14
11
|
510: "NOT_EXTENDED",
|
|
15
12
|
511: "NETWORK_AUTHENTICATION_REQUIRED"
|
|
16
13
|
});
|
|
17
|
-
class HttpServerError extends Error {
|
|
14
|
+
export class HttpServerError extends Error {
|
|
18
15
|
httpCode;
|
|
19
16
|
message;
|
|
20
17
|
data;
|
|
21
18
|
constructor({ httpCode, data, message }) {
|
|
22
19
|
super();
|
|
23
20
|
this.httpCode = httpCode;
|
|
24
|
-
this.message = !message?.trim() ?
|
|
21
|
+
this.message = !message?.trim() ? httpServerErrors[httpCode] : message.trim();
|
|
25
22
|
this.data = data;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
exports.HttpServerError = HttpServerError;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
require("reflect-metadata");
|
|
18
|
-
__exportStar(require("./interfaces"), exports);
|
|
19
|
-
__exportStar(require("./hooks"), exports);
|
|
20
|
-
__exportStar(require("./decorators"), exports);
|
|
21
|
-
__exportStar(require("./http"), exports);
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export * from "./interfaces";
|
|
3
|
+
export * from "./hooks";
|
|
4
|
+
export * from "./decorators";
|
|
5
|
+
export * from "./http";
|
package/dist/interfaces/index.js
CHANGED
package/dist/ultils/index.js
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./asyncFunction"), exports);
|
|
1
|
+
export * from "./asyncFunction";
|
package/package.json
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"typescript": "^5.4.5"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
2
|
+
"name": "@bool-ts/core",
|
|
3
|
+
"version": "1.4.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "bun --hot run __test/index.ts",
|
|
8
|
+
"build": "tsc"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/BoolTS/core.git"
|
|
13
|
+
},
|
|
14
|
+
"author": "Trần Đức Tâm (Neo)",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/BoolTS/core/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/BoolTS/core#readme",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"colors": "^1.4.0",
|
|
22
|
+
"qs": "^6.13.0",
|
|
23
|
+
"reflect-metadata": "^0.2.2",
|
|
24
|
+
"zod": "^3.23.8"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/bun": "^1.1.6",
|
|
28
|
+
"@types/qs": "^6.9.15",
|
|
29
|
+
"typescript": "^5.5.4"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import * as Zod from "zod";
|
|
2
|
+
|
|
3
|
+
export enum EArgumentTypes {
|
|
4
|
+
headers = "HEADERS",
|
|
5
|
+
body = "BODY",
|
|
6
|
+
params = "PARAMS",
|
|
7
|
+
param = "PARAM",
|
|
8
|
+
query = "QUERY",
|
|
9
|
+
request = "REQUEST"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type TMetadata =
|
|
13
|
+
| {
|
|
14
|
+
index: number;
|
|
15
|
+
type: EArgumentTypes.headers;
|
|
16
|
+
zodSchema?: Zod.Schema;
|
|
17
|
+
}
|
|
18
|
+
| {
|
|
19
|
+
index: number;
|
|
20
|
+
type: EArgumentTypes.body;
|
|
21
|
+
zodSchema?: Zod.Schema;
|
|
22
|
+
parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text";
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
index: number;
|
|
26
|
+
type: EArgumentTypes.params;
|
|
27
|
+
zodSchema?: Zod.Schema;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
index: number;
|
|
31
|
+
type: EArgumentTypes.param;
|
|
32
|
+
key: string;
|
|
33
|
+
zodSchema?: Zod.Schema;
|
|
34
|
+
}
|
|
35
|
+
| {
|
|
36
|
+
index: number;
|
|
37
|
+
type: EArgumentTypes.query;
|
|
38
|
+
zodSchema?: Zod.Schema;
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
index: number;
|
|
42
|
+
type: EArgumentTypes.request;
|
|
43
|
+
zodSchema?: Zod.Schema;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const controllerActionArgumentsKey = Symbol.for("__bool:controller.action::arguments__");
|
|
47
|
+
|
|
48
|
+
export const Headers = (zodSchema?: Zod.Schema) => {
|
|
49
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
50
|
+
if (!methodName) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const headersMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
55
|
+
|
|
56
|
+
headersMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
57
|
+
index: parameterIndex,
|
|
58
|
+
type: EArgumentTypes.headers,
|
|
59
|
+
zodSchema: zodSchema
|
|
60
|
+
} satisfies Extract<
|
|
61
|
+
TMetadata,
|
|
62
|
+
{
|
|
63
|
+
type: EArgumentTypes.headers;
|
|
64
|
+
}
|
|
65
|
+
>;
|
|
66
|
+
|
|
67
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, headersMetadata, target.constructor, methodName);
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const Body = (zodSchema?: Zod.Schema, parser?: "arrayBuffer" | "blob" | "formData" | "json" | "text") => {
|
|
72
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
73
|
+
if (!methodName) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const bodyMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
78
|
+
|
|
79
|
+
bodyMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
80
|
+
index: parameterIndex,
|
|
81
|
+
type: EArgumentTypes.body,
|
|
82
|
+
zodSchema: zodSchema,
|
|
83
|
+
parser: parser
|
|
84
|
+
} satisfies Extract<
|
|
85
|
+
TMetadata,
|
|
86
|
+
{
|
|
87
|
+
type: EArgumentTypes.body;
|
|
88
|
+
}
|
|
89
|
+
>;
|
|
90
|
+
|
|
91
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, bodyMetadata, target.constructor, methodName);
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const Params = (zodSchema?: Zod.Schema) => {
|
|
96
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
97
|
+
if (!methodName) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const paramsMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
102
|
+
|
|
103
|
+
paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
104
|
+
index: parameterIndex,
|
|
105
|
+
type: EArgumentTypes.params,
|
|
106
|
+
zodSchema: zodSchema
|
|
107
|
+
} satisfies Extract<
|
|
108
|
+
TMetadata,
|
|
109
|
+
{
|
|
110
|
+
type: EArgumentTypes.params;
|
|
111
|
+
}
|
|
112
|
+
>;
|
|
113
|
+
|
|
114
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, paramsMetadata, target.constructor, methodName);
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const Param = (key: string, zodSchema?: Zod.Schema) => {
|
|
119
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
120
|
+
if (!methodName) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const paramsMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
125
|
+
|
|
126
|
+
paramsMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
127
|
+
index: parameterIndex,
|
|
128
|
+
type: EArgumentTypes.param,
|
|
129
|
+
key: key,
|
|
130
|
+
zodSchema: zodSchema
|
|
131
|
+
} satisfies Extract<
|
|
132
|
+
TMetadata,
|
|
133
|
+
{
|
|
134
|
+
type: EArgumentTypes.param;
|
|
135
|
+
}
|
|
136
|
+
>;
|
|
137
|
+
|
|
138
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, paramsMetadata, target.constructor, methodName);
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const Query = (zodSchema?: Zod.Schema) => {
|
|
143
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
144
|
+
if (!methodName) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const queryMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
149
|
+
|
|
150
|
+
queryMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
151
|
+
index: parameterIndex,
|
|
152
|
+
type: EArgumentTypes.params,
|
|
153
|
+
zodSchema: zodSchema
|
|
154
|
+
} satisfies Extract<
|
|
155
|
+
TMetadata,
|
|
156
|
+
{
|
|
157
|
+
type: EArgumentTypes.params;
|
|
158
|
+
}
|
|
159
|
+
>;
|
|
160
|
+
|
|
161
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, queryMetadata, target.constructor, methodName);
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export const Request = (zodSchema?: Zod.Schema) => {
|
|
166
|
+
return (target: Object, methodName: string | symbol | undefined, parameterIndex: number) => {
|
|
167
|
+
if (!methodName) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const queryMetadata = Reflect.getOwnMetadata(controllerActionArgumentsKey, target.constructor, methodName) || {};
|
|
172
|
+
|
|
173
|
+
queryMetadata[`argumentIndexes.${parameterIndex}`] = {
|
|
174
|
+
index: parameterIndex,
|
|
175
|
+
type: EArgumentTypes.request,
|
|
176
|
+
zodSchema: zodSchema
|
|
177
|
+
} satisfies Extract<
|
|
178
|
+
TMetadata,
|
|
179
|
+
{
|
|
180
|
+
type: EArgumentTypes.request;
|
|
181
|
+
}
|
|
182
|
+
>;
|
|
183
|
+
|
|
184
|
+
Reflect.defineMetadata(controllerActionArgumentsKey, queryMetadata, target.constructor, methodName);
|
|
185
|
+
};
|
|
186
|
+
};
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { injectableKey } from "./injectable";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return target;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default Controller;
|
|
1
|
+
import { injectableKey } from "./injectable";
|
|
2
|
+
|
|
3
|
+
export const controllerKey = Symbol.for("__bool:controller__");
|
|
4
|
+
|
|
5
|
+
export const Controller =
|
|
6
|
+
(prefix: string) =>
|
|
7
|
+
<T extends Object>(target: T) => {
|
|
8
|
+
Reflect.defineMetadata(controllerKey, !prefix.startsWith("/") ? `/${prefix}` : prefix, target);
|
|
9
|
+
Reflect.defineMetadata(injectableKey, undefined, target);
|
|
10
|
+
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default Controller;
|