@dooboostore/simple-boot-http-server 1.0.18 → 1.0.19
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/cjs/SimpleBootHttpServer.d.ts +2 -1
- package/dist/cjs/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/cjs/SimpleBootHttpServer.js +53 -673
- package/dist/cjs/SimpleBootHttpServer.js.map +4 -4
- package/dist/cjs/codes/HttpHeaders.js +0 -2
- package/dist/cjs/codes/HttpHeaders.js.map +1 -1
- package/dist/cjs/codes/HttpMethod.js +0 -2
- package/dist/cjs/codes/HttpMethod.js.map +1 -1
- package/dist/cjs/codes/HttpStatus.js +0 -2
- package/dist/cjs/codes/HttpStatus.js.map +1 -1
- package/dist/cjs/codes/Mimes.js +0 -2
- package/dist/cjs/codes/Mimes.js.map +1 -1
- package/dist/cjs/codes/index.js +9 -126
- package/dist/cjs/codes/index.js.map +4 -4
- package/dist/cjs/decorators/MethodMapping.d.ts +0 -1
- package/dist/cjs/decorators/MethodMapping.d.ts.map +1 -1
- package/dist/cjs/decorators/MethodMapping.js +51 -53
- package/dist/cjs/decorators/MethodMapping.js.map +2 -2
- package/dist/cjs/decorators/index.js +3 -248
- package/dist/cjs/decorators/index.js.map +4 -4
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js +7 -8
- package/dist/cjs/endpoints/CrossDomainHeaderEndPoint.js.map +1 -1
- package/dist/cjs/endpoints/EndPoint.js +0 -2
- package/dist/cjs/endpoints/EndPoint.js.map +1 -1
- package/dist/cjs/endpoints/HeaderEndPoint.js +2 -4
- package/dist/cjs/endpoints/HeaderEndPoint.js.map +1 -1
- package/dist/cjs/endpoints/index.js +7 -54
- package/dist/cjs/endpoints/index.js.map +3 -3
- package/dist/cjs/errors/BadRequestError.js +5 -16
- package/dist/cjs/errors/BadRequestError.js.map +3 -3
- package/dist/cjs/errors/ForbiddenError.js +5 -16
- package/dist/cjs/errors/ForbiddenError.js.map +3 -3
- package/dist/cjs/errors/HttpError.js +7 -5
- package/dist/cjs/errors/HttpError.js.map +1 -1
- package/dist/cjs/errors/InternalServerError.js +5 -16
- package/dist/cjs/errors/InternalServerError.js.map +3 -3
- package/dist/cjs/errors/NotFoundError.js +5 -16
- package/dist/cjs/errors/NotFoundError.js.map +3 -3
- package/dist/cjs/errors/UnauthorizedError.js +5 -16
- package/dist/cjs/errors/UnauthorizedError.js.map +3 -3
- package/dist/cjs/errors/index.js +13 -64
- package/dist/cjs/errors/index.js.map +3 -3
- package/dist/cjs/filters/CacheFilter.js +14 -17
- package/dist/cjs/filters/CacheFilter.js.map +2 -2
- package/dist/cjs/filters/Filter.js +0 -2
- package/dist/cjs/filters/Filter.js.map +1 -1
- package/dist/cjs/filters/HttpStatusFilter.js +2 -4
- package/dist/cjs/filters/HttpStatusFilter.js.map +1 -1
- package/dist/cjs/filters/OpenApi3Filter.js +8 -20
- package/dist/cjs/filters/OpenApi3Filter.js.map +3 -3
- package/dist/cjs/filters/ResourceFilter.js +7 -7
- package/dist/cjs/filters/ResourceFilter.js.map +1 -1
- package/dist/cjs/filters/ThrowFilter.js +2 -4
- package/dist/cjs/filters/ThrowFilter.js.map +1 -1
- package/dist/cjs/filters/index.js +13 -299
- package/dist/cjs/filters/index.js.map +4 -4
- package/dist/cjs/index.d.ts +2 -12
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -1734
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/inject/InjectSituationType.js +0 -2
- package/dist/cjs/inject/InjectSituationType.js.map +1 -1
- package/dist/cjs/inject/index.js +3 -16
- package/dist/cjs/inject/index.js.map +4 -4
- package/dist/cjs/lifecycle/OnInit.js +0 -2
- package/dist/cjs/lifecycle/OnInit.js.map +1 -1
- package/dist/cjs/lifecycle/index.js +6 -2
- package/dist/cjs/lifecycle/index.js.map +1 -1
- package/dist/cjs/models/RequestResponse.js +26 -33
- package/dist/cjs/models/RequestResponse.js.map +3 -3
- package/dist/cjs/models/datas/HeaderData.js +2 -4
- package/dist/cjs/models/datas/HeaderData.js.map +1 -1
- package/dist/cjs/models/datas/MultipartData.js +0 -2
- package/dist/cjs/models/datas/MultipartData.js.map +1 -1
- package/dist/cjs/models/datas/ReqHeader.js +65 -4
- package/dist/cjs/models/datas/ReqHeader.js.map +1 -1
- package/dist/cjs/models/datas/Resource.js +8 -480
- package/dist/cjs/models/datas/Resource.js.map +4 -4
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js +2 -4
- package/dist/cjs/models/datas/body/ReqFormUrlBody.js.map +1 -1
- package/dist/cjs/models/datas/body/ReqJsonBody.js +2 -4
- package/dist/cjs/models/datas/body/ReqJsonBody.js.map +1 -1
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js +2 -4
- package/dist/cjs/models/datas/body/ReqMultipartFormBody.js.map +1 -1
- package/dist/cjs/models/index.js +19 -574
- package/dist/cjs/models/index.js.map +4 -4
- package/dist/cjs/models/method/patch/PatchJson.js +2 -4
- package/dist/cjs/models/method/patch/PatchJson.js.map +1 -1
- package/dist/cjs/option/HttpServerOption.js +16 -11
- package/dist/cjs/option/HttpServerOption.js.map +1 -1
- package/dist/cjs/option/index.js +3 -50
- package/dist/cjs/option/index.js.map +3 -3
- package/dist/cjs/resolvers/Resolver.js +0 -2
- package/dist/cjs/resolvers/Resolver.js.map +1 -1
- package/dist/cjs/resolvers/ResourceResolver.js +10 -538
- package/dist/cjs/resolvers/ResourceResolver.js.map +4 -4
- package/dist/cjs/resolvers/index.js +5 -552
- package/dist/cjs/resolvers/index.js.map +4 -4
- package/dist/cjs/session/SessionManager.js +6 -479
- package/dist/cjs/session/SessionManager.js.map +4 -4
- package/dist/cjs/session/index.js +3 -560
- package/dist/cjs/session/index.js.map +4 -4
- package/dist/esm/SimpleBootHttpServer.d.ts +2 -1
- package/dist/esm/SimpleBootHttpServer.d.ts.map +1 -1
- package/dist/esm/SimpleBootHttpServer.js +37 -656
- package/dist/esm/SimpleBootHttpServer.js.map +4 -4
- package/dist/esm/codes/HttpHeaders.js +0 -1
- package/dist/esm/codes/HttpHeaders.js.map +1 -1
- package/dist/esm/codes/HttpMethod.js +0 -1
- package/dist/esm/codes/HttpMethod.js.map +1 -1
- package/dist/esm/codes/HttpStatus.js +0 -1
- package/dist/esm/codes/HttpStatus.js.map +1 -1
- package/dist/esm/codes/Mimes.js +0 -1
- package/dist/esm/codes/Mimes.js.map +1 -1
- package/dist/esm/codes/index.js +4 -115
- package/dist/esm/codes/index.js.map +4 -4
- package/dist/esm/decorators/MethodMapping.d.ts +0 -1
- package/dist/esm/decorators/MethodMapping.d.ts.map +1 -1
- package/dist/esm/decorators/MethodMapping.js +51 -52
- package/dist/esm/decorators/MethodMapping.js.map +2 -2
- package/dist/esm/decorators/index.js +1 -210
- package/dist/esm/decorators/index.js.map +4 -4
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js +7 -7
- package/dist/esm/endpoints/CrossDomainHeaderEndPoint.js.map +1 -1
- package/dist/esm/endpoints/HeaderEndPoint.js +2 -3
- package/dist/esm/endpoints/HeaderEndPoint.js.map +1 -1
- package/dist/esm/endpoints/index.js +3 -45
- package/dist/esm/endpoints/index.js.map +3 -3
- package/dist/esm/errors/BadRequestError.js +5 -13
- package/dist/esm/errors/BadRequestError.js.map +3 -3
- package/dist/esm/errors/ForbiddenError.js +5 -13
- package/dist/esm/errors/ForbiddenError.js.map +3 -3
- package/dist/esm/errors/HttpError.js +7 -4
- package/dist/esm/errors/HttpError.js.map +1 -1
- package/dist/esm/errors/InternalServerError.js +5 -13
- package/dist/esm/errors/InternalServerError.js.map +3 -3
- package/dist/esm/errors/NotFoundError.js +5 -13
- package/dist/esm/errors/NotFoundError.js.map +3 -3
- package/dist/esm/errors/UnauthorizedError.js +5 -13
- package/dist/esm/errors/UnauthorizedError.js.map +3 -3
- package/dist/esm/errors/index.js +6 -51
- package/dist/esm/errors/index.js.map +3 -3
- package/dist/esm/filters/CacheFilter.js +14 -16
- package/dist/esm/filters/CacheFilter.js.map +2 -2
- package/dist/esm/filters/HttpStatusFilter.js +2 -3
- package/dist/esm/filters/HttpStatusFilter.js.map +1 -1
- package/dist/esm/filters/OpenApi3Filter.js +7 -16
- package/dist/esm/filters/OpenApi3Filter.js.map +3 -3
- package/dist/esm/filters/ResourceFilter.js +7 -6
- package/dist/esm/filters/ResourceFilter.js.map +1 -1
- package/dist/esm/filters/ThrowFilter.js +2 -3
- package/dist/esm/filters/ThrowFilter.js.map +1 -1
- package/dist/esm/filters/index.js +6 -277
- package/dist/esm/filters/index.js.map +4 -4
- package/dist/esm/index.d.ts +2 -12
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1659
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/inject/InjectSituationType.js +0 -1
- package/dist/esm/inject/InjectSituationType.js.map +1 -1
- package/dist/esm/inject/index.js +1 -8
- package/dist/esm/inject/index.js.map +4 -4
- package/dist/esm/lifecycle/index.js +1 -0
- package/dist/esm/lifecycle/index.js.map +3 -3
- package/dist/esm/models/RequestResponse.js +23 -29
- package/dist/esm/models/RequestResponse.js.map +3 -3
- package/dist/esm/models/datas/HeaderData.js +2 -3
- package/dist/esm/models/datas/HeaderData.js.map +1 -1
- package/dist/esm/models/datas/ReqHeader.js +65 -3
- package/dist/esm/models/datas/ReqHeader.js.map +1 -1
- package/dist/esm/models/datas/Resource.js +7 -478
- package/dist/esm/models/datas/Resource.js.map +4 -4
- package/dist/esm/models/datas/body/ReqFormUrlBody.js +2 -3
- package/dist/esm/models/datas/body/ReqFormUrlBody.js.map +1 -1
- package/dist/esm/models/datas/body/ReqJsonBody.js +2 -3
- package/dist/esm/models/datas/body/ReqJsonBody.js.map +1 -1
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js +2 -3
- package/dist/esm/models/datas/body/ReqMultipartFormBody.js.map +1 -1
- package/dist/esm/models/index.js +9 -548
- package/dist/esm/models/index.js.map +4 -4
- package/dist/esm/models/method/patch/PatchJson.js +2 -3
- package/dist/esm/models/method/patch/PatchJson.js.map +1 -1
- package/dist/esm/option/HttpServerOption.js +16 -10
- package/dist/esm/option/HttpServerOption.js.map +1 -1
- package/dist/esm/option/index.js +1 -42
- package/dist/esm/option/index.js.map +3 -3
- package/dist/esm/resolvers/ResourceResolver.js +8 -526
- package/dist/esm/resolvers/ResourceResolver.js.map +4 -4
- package/dist/esm/resolvers/index.js +2 -537
- package/dist/esm/resolvers/index.js.map +4 -4
- package/dist/esm/session/SessionManager.js +5 -477
- package/dist/esm/session/SessionManager.js.map +3 -3
- package/dist/esm/session/index.js +1 -552
- package/dist/esm/session/index.js.map +3 -3
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js +3 -1659
- package/dist/esm-bundle/dooboostore-simple-boot-http-server.esm.js.map +4 -4
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js +2 -1673
- package/dist/umd-bundle/dooboostore-simple-boot-http-server.umd.js.map +4 -4
- package/package.json +15 -12
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
// src/decorators/MethodMapping.ts
|
|
2
|
-
import "reflect-metadata";
|
|
3
1
|
import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
|
|
2
|
+
import { HttpMethod } from "../codes/HttpMethod.js";
|
|
4
3
|
var UrlMappingSituationType = /* @__PURE__ */ ((UrlMappingSituationType2) => {
|
|
5
4
|
UrlMappingSituationType2["REQ_JSON_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY";
|
|
6
5
|
UrlMappingSituationType2["REQ_FORM_URL_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY";
|
|
7
6
|
return UrlMappingSituationType2;
|
|
8
7
|
})(UrlMappingSituationType || {});
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const MappingMetadataKey = Symbol("MappingMetadataKey");
|
|
9
|
+
const process = (config, target, propertyKey, descriptor) => {
|
|
11
10
|
const saveMappingConfigs = ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? [];
|
|
12
11
|
saveMappingConfigs.push({ propertyKey, config });
|
|
13
12
|
ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);
|
|
@@ -15,17 +14,17 @@ var process = (config, target, propertyKey, descriptor) => {
|
|
|
15
14
|
};
|
|
16
15
|
function UrlMapping(configOrtarget, propertyKey, descriptor) {
|
|
17
16
|
if (propertyKey && descriptor) {
|
|
18
|
-
process({ method:
|
|
17
|
+
process({ method: HttpMethod.GET }, configOrtarget, propertyKey, descriptor);
|
|
19
18
|
} else {
|
|
20
19
|
return (target, propertyKey2, descriptor2) => {
|
|
21
20
|
process(configOrtarget, target, propertyKey2, descriptor2);
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
|
|
24
|
+
const getUrlMapping = (target, propertyKey) => {
|
|
26
25
|
return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);
|
|
27
26
|
};
|
|
28
|
-
|
|
27
|
+
const getUrlMappings = (target) => {
|
|
29
28
|
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
30
29
|
target = target.constructor;
|
|
31
30
|
}
|
|
@@ -33,147 +32,147 @@ var getUrlMappings = (target) => {
|
|
|
33
32
|
};
|
|
34
33
|
function GET(configOrTarget, propertyKey, descriptor) {
|
|
35
34
|
if (propertyKey && descriptor) {
|
|
36
|
-
process({ method:
|
|
35
|
+
process({ method: HttpMethod.GET }, configOrTarget, propertyKey, descriptor);
|
|
37
36
|
} else {
|
|
38
37
|
return (target, propertyKey2, descriptor2) => {
|
|
39
|
-
configOrTarget.method =
|
|
38
|
+
configOrTarget.method = HttpMethod.GET;
|
|
40
39
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
const getGET = (target, propertyKey) => {
|
|
45
44
|
return getUrlMapping(target, propertyKey);
|
|
46
45
|
};
|
|
47
|
-
|
|
48
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
46
|
+
const getGETS = (target) => {
|
|
47
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.GET);
|
|
49
48
|
};
|
|
50
49
|
function POST(configOrTarget, propertyKey, descriptor) {
|
|
51
50
|
if (propertyKey && descriptor) {
|
|
52
|
-
process({ method:
|
|
51
|
+
process({ method: HttpMethod.POST }, configOrTarget, propertyKey, descriptor);
|
|
53
52
|
} else {
|
|
54
53
|
return (target, propertyKey2, descriptor2) => {
|
|
55
|
-
configOrTarget.method =
|
|
54
|
+
configOrTarget.method = HttpMethod.POST;
|
|
56
55
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
const getPOST = (target, propertyKey) => {
|
|
61
60
|
return getUrlMapping(target, propertyKey);
|
|
62
61
|
};
|
|
63
|
-
|
|
64
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
62
|
+
const getPOSTS = (target) => {
|
|
63
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.POST);
|
|
65
64
|
};
|
|
66
65
|
function DELETE(configOrTarget, propertyKey, descriptor) {
|
|
67
66
|
if (propertyKey && descriptor) {
|
|
68
|
-
process({ method:
|
|
67
|
+
process({ method: HttpMethod.DELETE }, configOrTarget, propertyKey, descriptor);
|
|
69
68
|
} else {
|
|
70
69
|
return (target, propertyKey2, descriptor2) => {
|
|
71
|
-
configOrTarget.method =
|
|
70
|
+
configOrTarget.method = HttpMethod.DELETE;
|
|
72
71
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
73
72
|
};
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
|
-
|
|
75
|
+
const getDELETE = (target, propertyKey) => {
|
|
77
76
|
return getUrlMapping(target, propertyKey);
|
|
78
77
|
};
|
|
79
|
-
|
|
80
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
78
|
+
const getDELETES = (target) => {
|
|
79
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.DELETE);
|
|
81
80
|
};
|
|
82
81
|
function PUT(configOrTarget, propertyKey, descriptor) {
|
|
83
82
|
if (propertyKey && descriptor) {
|
|
84
|
-
process({ method:
|
|
83
|
+
process({ method: HttpMethod.PUT }, configOrTarget, propertyKey, descriptor);
|
|
85
84
|
} else {
|
|
86
85
|
return (target, propertyKey2, descriptor2) => {
|
|
87
|
-
configOrTarget.method =
|
|
86
|
+
configOrTarget.method = HttpMethod.PUT;
|
|
88
87
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
89
88
|
};
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
|
|
91
|
+
const getPUT = (target, propertyKey) => {
|
|
93
92
|
return getUrlMapping(target, propertyKey);
|
|
94
93
|
};
|
|
95
|
-
|
|
96
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
94
|
+
const getPUTS = (target) => {
|
|
95
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.PUT);
|
|
97
96
|
};
|
|
98
97
|
function PATCH(configOrTarget, propertyKey, descriptor) {
|
|
99
98
|
if (propertyKey && descriptor) {
|
|
100
|
-
process({ method:
|
|
99
|
+
process({ method: HttpMethod.PATCH }, configOrTarget, propertyKey, descriptor);
|
|
101
100
|
} else {
|
|
102
101
|
return (target, propertyKey2, descriptor2) => {
|
|
103
|
-
configOrTarget.method =
|
|
102
|
+
configOrTarget.method = HttpMethod.PATCH;
|
|
104
103
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
105
104
|
};
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
|
|
107
|
+
const getPATCH = (target, propertyKey) => {
|
|
109
108
|
return getUrlMapping(target, propertyKey);
|
|
110
109
|
};
|
|
111
|
-
|
|
112
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
110
|
+
const getPATCHS = (target) => {
|
|
111
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.GET);
|
|
113
112
|
};
|
|
114
113
|
function OPTIONS(configOrTarget, propertyKey, descriptor) {
|
|
115
114
|
if (propertyKey && descriptor) {
|
|
116
|
-
process({ method:
|
|
115
|
+
process({ method: HttpMethod.OPTIONS }, configOrTarget, propertyKey, descriptor);
|
|
117
116
|
} else {
|
|
118
117
|
return (target, propertyKey2, descriptor2) => {
|
|
119
|
-
configOrTarget.method =
|
|
118
|
+
configOrTarget.method = HttpMethod.OPTIONS;
|
|
120
119
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
121
120
|
};
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
|
|
123
|
+
const getOPTIONS = (target, propertyKey) => {
|
|
125
124
|
return getUrlMapping(target, propertyKey);
|
|
126
125
|
};
|
|
127
|
-
|
|
128
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
126
|
+
const getOPTIONSS = (target) => {
|
|
127
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);
|
|
129
128
|
};
|
|
130
129
|
function HEAD(configOrTarget, propertyKey, descriptor) {
|
|
131
130
|
if (propertyKey && descriptor) {
|
|
132
|
-
process({ method:
|
|
131
|
+
process({ method: HttpMethod.HEAD }, configOrTarget, propertyKey, descriptor);
|
|
133
132
|
} else {
|
|
134
133
|
return (target, propertyKey2, descriptor2) => {
|
|
135
|
-
configOrTarget.method =
|
|
134
|
+
configOrTarget.method = HttpMethod.HEAD;
|
|
136
135
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
137
136
|
};
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
|
-
|
|
139
|
+
const getHEAD = (target, propertyKey) => {
|
|
141
140
|
return getUrlMapping(target, propertyKey);
|
|
142
141
|
};
|
|
143
|
-
|
|
144
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
142
|
+
const getHEADS = (target) => {
|
|
143
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.GET);
|
|
145
144
|
};
|
|
146
145
|
function TRACE(configOrTarget, propertyKey, descriptor) {
|
|
147
146
|
if (propertyKey && descriptor) {
|
|
148
|
-
process({ method:
|
|
147
|
+
process({ method: HttpMethod.TRACE }, configOrTarget, propertyKey, descriptor);
|
|
149
148
|
} else {
|
|
150
149
|
return (target, propertyKey2, descriptor2) => {
|
|
151
|
-
configOrTarget.method =
|
|
150
|
+
configOrTarget.method = HttpMethod.TRACE;
|
|
152
151
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
153
152
|
};
|
|
154
153
|
}
|
|
155
154
|
}
|
|
156
|
-
|
|
155
|
+
const getTRACE = (target, propertyKey) => {
|
|
157
156
|
return getUrlMapping(target, propertyKey);
|
|
158
157
|
};
|
|
159
|
-
|
|
160
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
158
|
+
const getTRACES = (target) => {
|
|
159
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.TRACE);
|
|
161
160
|
};
|
|
162
161
|
function CONNECT(configOrTarget, propertyKey, descriptor) {
|
|
163
162
|
if (propertyKey && descriptor) {
|
|
164
|
-
process({ method:
|
|
163
|
+
process({ method: HttpMethod.CONNECT }, configOrTarget, propertyKey, descriptor);
|
|
165
164
|
} else {
|
|
166
165
|
return (target, propertyKey2, descriptor2) => {
|
|
167
|
-
configOrTarget.method =
|
|
166
|
+
configOrTarget.method = HttpMethod.CONNECT;
|
|
168
167
|
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
169
168
|
};
|
|
170
169
|
}
|
|
171
170
|
}
|
|
172
|
-
|
|
171
|
+
const getCONNECT = (target, propertyKey) => {
|
|
173
172
|
return getUrlMapping(target, propertyKey);
|
|
174
173
|
};
|
|
175
|
-
|
|
176
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() ===
|
|
174
|
+
const getCONNECTS = (target) => {
|
|
175
|
+
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === HttpMethod.CONNECT);
|
|
177
176
|
};
|
|
178
177
|
export {
|
|
179
178
|
CONNECT,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/decorators/MethodMapping.ts"],
|
|
4
|
-
"sourcesContent": ["import 'reflect-metadata';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { ReflectMethod } from '@dooboostore/simple-boot/types/Types';\nimport { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type MappingConfig = {\n method: HttpMethod | string,\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes|string)[];\n accept?: (Mimes|string)[];\n };\n\n res?: {\n status?: number;\n header?: {[key: string]: string};\n contentType?: Mimes | string;\n }\n resolver?: Resolver|ConstructorType<Resolver>;\n}\nexport type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}\nconst MappingMetadataKey = Symbol('MappingMetadataKey');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({propertyKey, config});\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n}\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n }\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n}\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n}\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.POST}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n}\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.DELETE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n}\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PUT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n}\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PATCH}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.OPTIONS}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n}\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.HEAD}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.TRACE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n}\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.CONNECT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { ConstructorType } from '@dooboostore/core/types';\nimport { ReflectMethod } from '@dooboostore/simple-boot/types/Types';\nimport { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type MappingConfig = {\n method: HttpMethod | string,\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes|string)[];\n accept?: (Mimes|string)[];\n };\n\n res?: {\n status?: number;\n header?: {[key: string]: string};\n contentType?: Mimes | string;\n }\n resolver?: Resolver|ConstructorType<Resolver>;\n}\nexport type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}\nconst MappingMetadataKey = Symbol('MappingMetadataKey');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({propertyKey, config});\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n}\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n }\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n}\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n}\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.POST}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n}\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.DELETE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n}\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PUT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n}\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PATCH}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.OPTIONS}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n}\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.HEAD}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.TRACE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n}\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.CONNECT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAEpB,IAAK,0BAAL,kBAAKA,6BAAL;AACH,EAAAA,yBAAA,mBAAgB;AAChB,EAAAA,yBAAA,uBAAoB;AAFZ,SAAAA;AAAA,GAAA;AAwBZ,MAAM,qBAAqB,OAAO,oBAAoB;AAItD,MAAM,UAAU,CAAC,QAAuB,QAAa,aAA8B,eAAmC;AAClH,QAAM,qBAAsB,aAAa,YAAY,oBAA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,aAAa,CAAC,QAAa,gBAA4D;AAChG,SAAO,cAAc,QAAQ,WAAW;AAC5C;AACO,MAAM,cAAc,CAAC,WAAqC;AAC7D,SAAO,eAAe,MAAM,GAAG,OAAO,QAAM,GAAG,QAAQ,OAAO,YAAY,MAAM,WAAW,OAAO;AACtG;",
|
|
6
6
|
"names": ["UrlMappingSituationType", "propertyKey", "descriptor"]
|
|
7
7
|
}
|
|
@@ -1,211 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import "reflect-metadata";
|
|
3
|
-
import { ReflectUtils } from "@dooboostore/core/reflect/ReflectUtils";
|
|
4
|
-
var UrlMappingSituationType = /* @__PURE__ */ ((UrlMappingSituationType2) => {
|
|
5
|
-
UrlMappingSituationType2["REQ_JSON_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY";
|
|
6
|
-
UrlMappingSituationType2["REQ_FORM_URL_BODY"] = "SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY";
|
|
7
|
-
return UrlMappingSituationType2;
|
|
8
|
-
})(UrlMappingSituationType || {});
|
|
9
|
-
var MappingMetadataKey = Symbol("MappingMetadataKey");
|
|
10
|
-
var process = (config, target, propertyKey, descriptor) => {
|
|
11
|
-
const saveMappingConfigs = ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? [];
|
|
12
|
-
saveMappingConfigs.push({ propertyKey, config });
|
|
13
|
-
ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);
|
|
14
|
-
ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);
|
|
15
|
-
};
|
|
16
|
-
function UrlMapping(configOrtarget, propertyKey, descriptor) {
|
|
17
|
-
if (propertyKey && descriptor) {
|
|
18
|
-
process({ method: "GET" /* GET */ }, configOrtarget, propertyKey, descriptor);
|
|
19
|
-
} else {
|
|
20
|
-
return (target, propertyKey2, descriptor2) => {
|
|
21
|
-
process(configOrtarget, target, propertyKey2, descriptor2);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
var getUrlMapping = (target, propertyKey) => {
|
|
26
|
-
return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);
|
|
27
|
-
};
|
|
28
|
-
var getUrlMappings = (target) => {
|
|
29
|
-
if (target !== null && void 0 !== target && typeof target === "object") {
|
|
30
|
-
target = target.constructor;
|
|
31
|
-
}
|
|
32
|
-
return ReflectUtils.getMetadata(MappingMetadataKey, target);
|
|
33
|
-
};
|
|
34
|
-
function GET(configOrTarget, propertyKey, descriptor) {
|
|
35
|
-
if (propertyKey && descriptor) {
|
|
36
|
-
process({ method: "GET" /* GET */ }, configOrTarget, propertyKey, descriptor);
|
|
37
|
-
} else {
|
|
38
|
-
return (target, propertyKey2, descriptor2) => {
|
|
39
|
-
configOrTarget.method = "GET" /* GET */;
|
|
40
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
var getGET = (target, propertyKey) => {
|
|
45
|
-
return getUrlMapping(target, propertyKey);
|
|
46
|
-
};
|
|
47
|
-
var getGETS = (target) => {
|
|
48
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
49
|
-
};
|
|
50
|
-
function POST(configOrTarget, propertyKey, descriptor) {
|
|
51
|
-
if (propertyKey && descriptor) {
|
|
52
|
-
process({ method: "POST" /* POST */ }, configOrTarget, propertyKey, descriptor);
|
|
53
|
-
} else {
|
|
54
|
-
return (target, propertyKey2, descriptor2) => {
|
|
55
|
-
configOrTarget.method = "POST" /* POST */;
|
|
56
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
var getPOST = (target, propertyKey) => {
|
|
61
|
-
return getUrlMapping(target, propertyKey);
|
|
62
|
-
};
|
|
63
|
-
var getPOSTS = (target) => {
|
|
64
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "POST" /* POST */);
|
|
65
|
-
};
|
|
66
|
-
function DELETE(configOrTarget, propertyKey, descriptor) {
|
|
67
|
-
if (propertyKey && descriptor) {
|
|
68
|
-
process({ method: "DELETE" /* DELETE */ }, configOrTarget, propertyKey, descriptor);
|
|
69
|
-
} else {
|
|
70
|
-
return (target, propertyKey2, descriptor2) => {
|
|
71
|
-
configOrTarget.method = "DELETE" /* DELETE */;
|
|
72
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
var getDELETE = (target, propertyKey) => {
|
|
77
|
-
return getUrlMapping(target, propertyKey);
|
|
78
|
-
};
|
|
79
|
-
var getDELETES = (target) => {
|
|
80
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "DELETE" /* DELETE */);
|
|
81
|
-
};
|
|
82
|
-
function PUT(configOrTarget, propertyKey, descriptor) {
|
|
83
|
-
if (propertyKey && descriptor) {
|
|
84
|
-
process({ method: "PUT" /* PUT */ }, configOrTarget, propertyKey, descriptor);
|
|
85
|
-
} else {
|
|
86
|
-
return (target, propertyKey2, descriptor2) => {
|
|
87
|
-
configOrTarget.method = "PUT" /* PUT */;
|
|
88
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
var getPUT = (target, propertyKey) => {
|
|
93
|
-
return getUrlMapping(target, propertyKey);
|
|
94
|
-
};
|
|
95
|
-
var getPUTS = (target) => {
|
|
96
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "PUT" /* PUT */);
|
|
97
|
-
};
|
|
98
|
-
function PATCH(configOrTarget, propertyKey, descriptor) {
|
|
99
|
-
if (propertyKey && descriptor) {
|
|
100
|
-
process({ method: "PATCH" /* PATCH */ }, configOrTarget, propertyKey, descriptor);
|
|
101
|
-
} else {
|
|
102
|
-
return (target, propertyKey2, descriptor2) => {
|
|
103
|
-
configOrTarget.method = "PATCH" /* PATCH */;
|
|
104
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
var getPATCH = (target, propertyKey) => {
|
|
109
|
-
return getUrlMapping(target, propertyKey);
|
|
110
|
-
};
|
|
111
|
-
var getPATCHS = (target) => {
|
|
112
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
113
|
-
};
|
|
114
|
-
function OPTIONS(configOrTarget, propertyKey, descriptor) {
|
|
115
|
-
if (propertyKey && descriptor) {
|
|
116
|
-
process({ method: "OPTIONS" /* OPTIONS */ }, configOrTarget, propertyKey, descriptor);
|
|
117
|
-
} else {
|
|
118
|
-
return (target, propertyKey2, descriptor2) => {
|
|
119
|
-
configOrTarget.method = "OPTIONS" /* OPTIONS */;
|
|
120
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
var getOPTIONS = (target, propertyKey) => {
|
|
125
|
-
return getUrlMapping(target, propertyKey);
|
|
126
|
-
};
|
|
127
|
-
var getOPTIONSS = (target) => {
|
|
128
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "OPTIONS" /* OPTIONS */);
|
|
129
|
-
};
|
|
130
|
-
function HEAD(configOrTarget, propertyKey, descriptor) {
|
|
131
|
-
if (propertyKey && descriptor) {
|
|
132
|
-
process({ method: "HEAD" /* HEAD */ }, configOrTarget, propertyKey, descriptor);
|
|
133
|
-
} else {
|
|
134
|
-
return (target, propertyKey2, descriptor2) => {
|
|
135
|
-
configOrTarget.method = "HEAD" /* HEAD */;
|
|
136
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
var getHEAD = (target, propertyKey) => {
|
|
141
|
-
return getUrlMapping(target, propertyKey);
|
|
142
|
-
};
|
|
143
|
-
var getHEADS = (target) => {
|
|
144
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "GET" /* GET */);
|
|
145
|
-
};
|
|
146
|
-
function TRACE(configOrTarget, propertyKey, descriptor) {
|
|
147
|
-
if (propertyKey && descriptor) {
|
|
148
|
-
process({ method: "TRACE" /* TRACE */ }, configOrTarget, propertyKey, descriptor);
|
|
149
|
-
} else {
|
|
150
|
-
return (target, propertyKey2, descriptor2) => {
|
|
151
|
-
configOrTarget.method = "TRACE" /* TRACE */;
|
|
152
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
var getTRACE = (target, propertyKey) => {
|
|
157
|
-
return getUrlMapping(target, propertyKey);
|
|
158
|
-
};
|
|
159
|
-
var getTRACES = (target) => {
|
|
160
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "TRACE" /* TRACE */);
|
|
161
|
-
};
|
|
162
|
-
function CONNECT(configOrTarget, propertyKey, descriptor) {
|
|
163
|
-
if (propertyKey && descriptor) {
|
|
164
|
-
process({ method: "CONNECT" /* CONNECT */ }, configOrTarget, propertyKey, descriptor);
|
|
165
|
-
} else {
|
|
166
|
-
return (target, propertyKey2, descriptor2) => {
|
|
167
|
-
configOrTarget.method = "CONNECT" /* CONNECT */;
|
|
168
|
-
process(configOrTarget, target, propertyKey2, descriptor2);
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
var getCONNECT = (target, propertyKey) => {
|
|
173
|
-
return getUrlMapping(target, propertyKey);
|
|
174
|
-
};
|
|
175
|
-
var getCONNECTS = (target) => {
|
|
176
|
-
return getUrlMappings(target)?.filter((it) => it.config?.method.toUpperCase() === "CONNECT" /* CONNECT */);
|
|
177
|
-
};
|
|
178
|
-
export {
|
|
179
|
-
CONNECT,
|
|
180
|
-
DELETE,
|
|
181
|
-
GET,
|
|
182
|
-
HEAD,
|
|
183
|
-
OPTIONS,
|
|
184
|
-
PATCH,
|
|
185
|
-
POST,
|
|
186
|
-
PUT,
|
|
187
|
-
TRACE,
|
|
188
|
-
UrlMapping,
|
|
189
|
-
UrlMappingSituationType,
|
|
190
|
-
getCONNECT,
|
|
191
|
-
getCONNECTS,
|
|
192
|
-
getDELETE,
|
|
193
|
-
getDELETES,
|
|
194
|
-
getGET,
|
|
195
|
-
getGETS,
|
|
196
|
-
getHEAD,
|
|
197
|
-
getHEADS,
|
|
198
|
-
getOPTIONS,
|
|
199
|
-
getOPTIONSS,
|
|
200
|
-
getPATCH,
|
|
201
|
-
getPATCHS,
|
|
202
|
-
getPOST,
|
|
203
|
-
getPOSTS,
|
|
204
|
-
getPUT,
|
|
205
|
-
getPUTS,
|
|
206
|
-
getTRACE,
|
|
207
|
-
getTRACES,
|
|
208
|
-
getUrlMapping,
|
|
209
|
-
getUrlMappings
|
|
210
|
-
};
|
|
1
|
+
export * from "./MethodMapping.js";
|
|
211
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/decorators/
|
|
4
|
-
"sourcesContent": ["import 'reflect-metadata';\nimport { ConstructorType } from '@dooboostore/core/types';\nimport { ReflectMethod } from '@dooboostore/simple-boot/types/Types';\nimport { ReflectUtils } from '@dooboostore/core/reflect/ReflectUtils';\nimport { Resolver } from '../resolvers/Resolver';\nimport { Mimes } from '../codes/Mimes';\nimport { HttpMethod } from '../codes/HttpMethod';\n\nexport enum UrlMappingSituationType {\n REQ_JSON_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_JSON_BODY',\n REQ_FORM_URL_BODY = 'SIMPLE_BOOT_HTTP_SERVER://URLMAPPING/REQ_FORM_URL_BODY'\n}\nexport type MappingConfig = {\n method: HttpMethod | string,\n description?: {\n name?: string;\n detail?: string;\n };\n\n req?: {\n contentType?: (Mimes|string)[];\n accept?: (Mimes|string)[];\n };\n\n res?: {\n status?: number;\n header?: {[key: string]: string};\n contentType?: Mimes | string;\n }\n resolver?: Resolver|ConstructorType<Resolver>;\n}\nexport type SaveMappingConfig = {propertyKey: string | symbol; config: MappingConfig}\nconst MappingMetadataKey = Symbol('MappingMetadataKey');\n// const GETSMappingMetadataKey = Symbol('GET_METHODS');\n// const GETMappingMetadataKey = Symbol('GET_METHOD');\n\nconst process = (config: MappingConfig, target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n const saveMappingConfigs = (ReflectUtils.getMetadata(MappingMetadataKey, target.constructor) ?? []) as SaveMappingConfig[];\n saveMappingConfigs.push({propertyKey, config});\n ReflectUtils.defineMetadata(MappingMetadataKey, saveMappingConfigs, target.constructor);\n ReflectUtils.defineMetadata(MappingMetadataKey, config, target, propertyKey);\n}\nexport function UrlMapping(config: MappingConfig): ReflectMethod;\nexport function UrlMapping(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function UrlMapping(configOrtarget?: MappingConfig | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrtarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n process(configOrtarget, target, propertyKey, descriptor);\n }\n }\n}\nexport const getUrlMapping = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return ReflectUtils.getMetadata(MappingMetadataKey, target, propertyKey);\n}\n\nexport const getUrlMappings = (target: any): SaveMappingConfig[] => {\n if (target !== null && undefined !== target && typeof target === 'object') {\n target = target.constructor;\n }\n return ReflectUtils.getMetadata(MappingMetadataKey, target);\n}\nexport function GET(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function GET(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function GET(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.GET}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.GET;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getGET = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getGETS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function POST(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function POST(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function POST(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.POST}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.POST;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPOST = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPOSTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.POST);\n}\nexport function DELETE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function DELETE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function DELETE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.DELETE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.DELETE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getDELETE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getDELETES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.DELETE);\n}\nexport function PUT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PUT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PUT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PUT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PUT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPUT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPUTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.PUT);\n}\nexport function PATCH(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function PATCH(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function PATCH(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.PATCH}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.PATCH;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getPATCH = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getPATCHS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function OPTIONS(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function OPTIONS(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function OPTIONS(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.OPTIONS}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.OPTIONS;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getOPTIONS = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getOPTIONSS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.OPTIONS);\n}\nexport function HEAD(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function HEAD(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function HEAD(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.HEAD}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.HEAD;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getHEAD = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getHEADS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.GET);\n}\nexport function TRACE(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function TRACE(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function TRACE(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.TRACE}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.TRACE;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getTRACE = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getTRACES = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.TRACE);\n}\nexport function CONNECT(config: Omit<MappingConfig, 'method'>): ReflectMethod;\nexport function CONNECT(target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\nexport function CONNECT(configOrTarget?: Omit<MappingConfig, 'method'> | any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor): ReflectMethod | void {\n if (propertyKey && descriptor) {\n process({method: HttpMethod.CONNECT}, configOrTarget, propertyKey, descriptor);\n } else {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n configOrTarget.method = HttpMethod.CONNECT;\n process(configOrTarget, target, propertyKey, descriptor);\n }\n }\n}\n\nexport const getCONNECT = (target: any, propertyKey: string | symbol): MappingConfig | undefined => {\n return getUrlMapping(target, propertyKey);\n}\nexport const getCONNECTS = (target: any): SaveMappingConfig[] => {\n return getUrlMappings(target)?.filter(it => it.config?.method.toUpperCase() === HttpMethod.CONNECT);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
3
|
+
"sources": ["../../../src/decorators/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './MethodMapping';\n"],
|
|
5
|
+
"mappings": "AAAA,cAAc;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { HttpHeaders } from "../codes/HttpHeaders.js";
|
|
2
|
+
class CrossDomainHeaderEndPoint {
|
|
3
3
|
constructor(config) {
|
|
4
4
|
this.config = config;
|
|
5
5
|
}
|
|
@@ -10,21 +10,21 @@ var CrossDomainHeaderEndPoint = class {
|
|
|
10
10
|
*/
|
|
11
11
|
async endPoint(rr, app) {
|
|
12
12
|
if (this.config?.accessControlAllowOrigin) {
|
|
13
|
-
rr.resSetHeader(
|
|
13
|
+
rr.resSetHeader(HttpHeaders.AccessControlAllowOrigin, Array.isArray(this.config.accessControlAllowOrigin) ? this.config.accessControlAllowOrigin.join(", ") : this.config.accessControlAllowOrigin);
|
|
14
14
|
}
|
|
15
15
|
if (this.config?.accessControlAllowMethods) {
|
|
16
|
-
rr.resSetHeader(
|
|
16
|
+
rr.resSetHeader(HttpHeaders.AccessControlAllowMethods, Array.isArray(this.config.accessControlAllowMethods) ? this.config.accessControlAllowMethods.join(", ") : this.config.accessControlAllowMethods);
|
|
17
17
|
}
|
|
18
18
|
if (this.config?.accessControlAllowHeaders) {
|
|
19
|
-
rr.resSetHeader(
|
|
19
|
+
rr.resSetHeader(HttpHeaders.AccessControlAllowHeaders, Array.isArray(this.config.accessControlAllowHeaders) ? this.config.accessControlAllowHeaders.join(", ") : this.config.accessControlAllowHeaders);
|
|
20
20
|
}
|
|
21
21
|
if (this.config?.accessControlExposeHeaders) {
|
|
22
|
-
rr.resSetHeader(
|
|
22
|
+
rr.resSetHeader(HttpHeaders.AccessControlExposeHeaders, Array.isArray(this.config.accessControlExposeHeaders) ? this.config.accessControlExposeHeaders.join(", ") : this.config.accessControlExposeHeaders);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
async onInit(app) {
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
export {
|
|
29
29
|
CrossDomainHeaderEndPoint
|
|
30
30
|
};
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/endpoints/CrossDomainHeaderEndPoint.ts"],
|
|
4
4
|
"sourcesContent": ["import {EndPoint} from './EndPoint';\nimport {SimpleBootHttpServer} from '../SimpleBootHttpServer';\nimport {RequestResponse} from '../models/RequestResponse';\nimport { HttpHeaders } from '../codes/HttpHeaders';\n\nexport type CrossDomainHeaderEndPointConfig = {\n accessControlAllowOrigin?: string | string[],\n accessControlAllowMethods?: string | string[],\n accessControlAllowHeaders?: string | string[],\n accessControlExposeHeaders?: string | string[]\n}\nexport class CrossDomainHeaderEndPoint implements EndPoint {\n constructor(private config?: CrossDomainHeaderEndPointConfig) {\n }\n\n /*\n rr.resSetHeader(\"Access-Control-Allow-Origin\", \"*\")\n rr.resSetHeader(\"Access-Control-Allow-Methods\", \"DELETE, POST, GET, OPTIONS\")\n rr.resSetHeader(\"Access-Control-Allow-Headers\", \"Content-Type, Authorization, X-Requested-With\")\n */\n async endPoint(rr: RequestResponse, app: SimpleBootHttpServer) {\n if (this.config?.accessControlAllowOrigin) {\n rr.resSetHeader(HttpHeaders.AccessControlAllowOrigin, Array.isArray(this.config.accessControlAllowOrigin) ? this.config.accessControlAllowOrigin.join(', ') : this.config.accessControlAllowOrigin);\n }\n if (this.config?.accessControlAllowMethods) {\n rr.resSetHeader(HttpHeaders.AccessControlAllowMethods, Array.isArray(this.config.accessControlAllowMethods) ? this.config.accessControlAllowMethods.join(', ') : this.config.accessControlAllowMethods);\n }\n if (this.config?.accessControlAllowHeaders) {\n rr.resSetHeader(HttpHeaders.AccessControlAllowHeaders, Array.isArray(this.config.accessControlAllowHeaders) ? this.config.accessControlAllowHeaders.join(', ') : this.config.accessControlAllowHeaders);\n }\n if (this.config?.accessControlExposeHeaders) {\n rr.resSetHeader(HttpHeaders.AccessControlExposeHeaders, Array.isArray(this.config.accessControlExposeHeaders) ? this.config.accessControlExposeHeaders.join(', ') : this.config.accessControlExposeHeaders);\n }\n }\n\n async onInit(app: SimpleBootHttpServer) {\n }\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
5
|
+
"mappings": "AAGA,SAAS,mBAAmB;AAQrB,MAAM,0BAA8C;AAAA,EACvD,YAAoB,QAA0C;AAA1C;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,SAAS,IAAqB,KAA2B;AAC3D,QAAI,KAAK,QAAQ,0BAA0B;AACvC,SAAG,aAAa,YAAY,0BAA0B,MAAM,QAAQ,KAAK,OAAO,wBAAwB,IAAI,KAAK,OAAO,yBAAyB,KAAK,IAAI,IAAI,KAAK,OAAO,wBAAwB;AAAA,IACtM;AACA,QAAI,KAAK,QAAQ,2BAA2B;AACxC,SAAG,aAAa,YAAY,2BAA2B,MAAM,QAAQ,KAAK,OAAO,yBAAyB,IAAI,KAAK,OAAO,0BAA0B,KAAK,IAAI,IAAI,KAAK,OAAO,yBAAyB;AAAA,IAC1M;AACA,QAAI,KAAK,QAAQ,2BAA2B;AACxC,SAAG,aAAa,YAAY,2BAA2B,MAAM,QAAQ,KAAK,OAAO,yBAAyB,IAAI,KAAK,OAAO,0BAA0B,KAAK,IAAI,IAAI,KAAK,OAAO,yBAAyB;AAAA,IAC1M;AACA,QAAI,KAAK,QAAQ,4BAA4B;AACzC,SAAG,aAAa,YAAY,4BAA4B,MAAM,QAAQ,KAAK,OAAO,0BAA0B,IAAI,KAAK,OAAO,2BAA2B,KAAK,IAAI,IAAI,KAAK,OAAO,0BAA0B;AAAA,IAC9M;AAAA,EACJ;AAAA,EAEA,MAAM,OAAO,KAA2B;AAAA,EACxC;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|