moost 0.2.14 → 0.2.16
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/index.cjs +3 -184
- package/dist/index.d.ts +0 -5
- package/dist/index.mjs +4 -184
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var eventCore = require('@wooksjs/event-core');
|
|
4
|
-
require('url');
|
|
5
|
-
require('stream');
|
|
6
|
-
require('wooks');
|
|
7
|
-
require('http');
|
|
8
3
|
var mate = require('@prostojs/mate');
|
|
9
4
|
var infact = require('@prostojs/infact');
|
|
5
|
+
var eventCore = require('@wooksjs/event-core');
|
|
10
6
|
var valido$1 = require('@prostojs/valido');
|
|
11
7
|
|
|
12
8
|
/******************************************************************************
|
|
@@ -34,171 +30,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
34
30
|
});
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
function useHttpContext() {
|
|
38
|
-
return eventCore.useEventContext('HTTP');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const httpStatusCodes = {
|
|
42
|
-
[100]: 'Continue',
|
|
43
|
-
[101]: 'Switching protocols',
|
|
44
|
-
[102]: 'Processing',
|
|
45
|
-
[103]: 'Early Hints',
|
|
46
|
-
[200]: 'OK',
|
|
47
|
-
[201]: 'Created',
|
|
48
|
-
[202]: 'Accepted',
|
|
49
|
-
[203]: 'Non-Authoritative Information',
|
|
50
|
-
[204]: 'No Content',
|
|
51
|
-
[205]: 'Reset Content',
|
|
52
|
-
[206]: 'Partial Content',
|
|
53
|
-
[207]: 'Multi-Status',
|
|
54
|
-
[208]: 'Already Reported',
|
|
55
|
-
[226]: 'IM Used',
|
|
56
|
-
[300]: 'Multiple Choices',
|
|
57
|
-
[301]: 'Moved Permanently',
|
|
58
|
-
[302]: 'Found (Previously "Moved Temporarily")',
|
|
59
|
-
[303]: 'See Other',
|
|
60
|
-
[304]: 'Not Modified',
|
|
61
|
-
[305]: 'Use Proxy',
|
|
62
|
-
[306]: 'Switch Proxy',
|
|
63
|
-
[307]: 'Temporary Redirect',
|
|
64
|
-
[308]: 'Permanent Redirect',
|
|
65
|
-
[400]: 'Bad Request',
|
|
66
|
-
[401]: 'Unauthorized',
|
|
67
|
-
[402]: 'Payment Required',
|
|
68
|
-
[403]: 'Forbidden',
|
|
69
|
-
[404]: 'Not Found',
|
|
70
|
-
[405]: 'Method Not Allowed',
|
|
71
|
-
[406]: 'Not Acceptable',
|
|
72
|
-
[407]: 'Proxy Authentication Required',
|
|
73
|
-
[408]: 'Request Timeout',
|
|
74
|
-
[409]: 'Conflict',
|
|
75
|
-
[410]: 'Gone',
|
|
76
|
-
[411]: 'Length Required',
|
|
77
|
-
[412]: 'Precondition Failed',
|
|
78
|
-
[413]: 'Payload Too Large',
|
|
79
|
-
[414]: 'URI Too Long',
|
|
80
|
-
[415]: 'Unsupported Media Type',
|
|
81
|
-
[416]: 'Range Not Satisfiable',
|
|
82
|
-
[417]: 'Expectation Failed',
|
|
83
|
-
[418]: 'I\'m a Teapot',
|
|
84
|
-
[421]: 'Misdirected Request',
|
|
85
|
-
[422]: 'Unprocessable Entity',
|
|
86
|
-
[423]: 'Locked',
|
|
87
|
-
[424]: 'Failed Dependency',
|
|
88
|
-
[425]: 'Too Early',
|
|
89
|
-
[426]: 'Upgrade Required',
|
|
90
|
-
[428]: 'Precondition Required',
|
|
91
|
-
[429]: 'Too Many Requests',
|
|
92
|
-
[431]: 'Request Header Fields Too Large',
|
|
93
|
-
[451]: 'Unavailable For Legal Reasons',
|
|
94
|
-
[500]: 'Internal Server Error',
|
|
95
|
-
[501]: 'Not Implemented',
|
|
96
|
-
[502]: 'Bad Gateway',
|
|
97
|
-
[503]: 'Service Unavailable',
|
|
98
|
-
[504]: 'Gateway Timeout',
|
|
99
|
-
[505]: 'HTTP Version Not Supported',
|
|
100
|
-
[506]: 'Variant Also Negotiates',
|
|
101
|
-
[507]: 'Insufficient Storage',
|
|
102
|
-
[508]: 'Loop Detected',
|
|
103
|
-
[510]: 'Not Extended',
|
|
104
|
-
[511]: 'Network Authentication Required',
|
|
105
|
-
};
|
|
106
|
-
var EHttpStatusCode;
|
|
107
|
-
(function (EHttpStatusCode) {
|
|
108
|
-
EHttpStatusCode[EHttpStatusCode["Continue"] = 100] = "Continue";
|
|
109
|
-
EHttpStatusCode[EHttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
110
|
-
EHttpStatusCode[EHttpStatusCode["Processing"] = 102] = "Processing";
|
|
111
|
-
EHttpStatusCode[EHttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
|
|
112
|
-
EHttpStatusCode[EHttpStatusCode["OK"] = 200] = "OK";
|
|
113
|
-
EHttpStatusCode[EHttpStatusCode["Created"] = 201] = "Created";
|
|
114
|
-
EHttpStatusCode[EHttpStatusCode["Accepted"] = 202] = "Accepted";
|
|
115
|
-
EHttpStatusCode[EHttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
116
|
-
EHttpStatusCode[EHttpStatusCode["NoContent"] = 204] = "NoContent";
|
|
117
|
-
EHttpStatusCode[EHttpStatusCode["ResetContent"] = 205] = "ResetContent";
|
|
118
|
-
EHttpStatusCode[EHttpStatusCode["PartialContent"] = 206] = "PartialContent";
|
|
119
|
-
EHttpStatusCode[EHttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
|
|
120
|
-
EHttpStatusCode[EHttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
121
|
-
EHttpStatusCode[EHttpStatusCode["IMUsed"] = 226] = "IMUsed";
|
|
122
|
-
EHttpStatusCode[EHttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
123
|
-
EHttpStatusCode[EHttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
124
|
-
EHttpStatusCode[EHttpStatusCode["Found"] = 302] = "Found";
|
|
125
|
-
EHttpStatusCode[EHttpStatusCode["SeeOther"] = 303] = "SeeOther";
|
|
126
|
-
EHttpStatusCode[EHttpStatusCode["NotModified"] = 304] = "NotModified";
|
|
127
|
-
EHttpStatusCode[EHttpStatusCode["UseProxy"] = 305] = "UseProxy";
|
|
128
|
-
EHttpStatusCode[EHttpStatusCode["SwitchProxy"] = 306] = "SwitchProxy";
|
|
129
|
-
EHttpStatusCode[EHttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
130
|
-
EHttpStatusCode[EHttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
131
|
-
EHttpStatusCode[EHttpStatusCode["BadRequest"] = 400] = "BadRequest";
|
|
132
|
-
EHttpStatusCode[EHttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
|
|
133
|
-
EHttpStatusCode[EHttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
134
|
-
EHttpStatusCode[EHttpStatusCode["Forbidden"] = 403] = "Forbidden";
|
|
135
|
-
EHttpStatusCode[EHttpStatusCode["NotFound"] = 404] = "NotFound";
|
|
136
|
-
EHttpStatusCode[EHttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
137
|
-
EHttpStatusCode[EHttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
138
|
-
EHttpStatusCode[EHttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
139
|
-
EHttpStatusCode[EHttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
140
|
-
EHttpStatusCode[EHttpStatusCode["Conflict"] = 409] = "Conflict";
|
|
141
|
-
EHttpStatusCode[EHttpStatusCode["Gone"] = 410] = "Gone";
|
|
142
|
-
EHttpStatusCode[EHttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
|
|
143
|
-
EHttpStatusCode[EHttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
144
|
-
EHttpStatusCode[EHttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
145
|
-
EHttpStatusCode[EHttpStatusCode["URITooLong"] = 414] = "URITooLong";
|
|
146
|
-
EHttpStatusCode[EHttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
147
|
-
EHttpStatusCode[EHttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
148
|
-
EHttpStatusCode[EHttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
149
|
-
EHttpStatusCode[EHttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
|
|
150
|
-
EHttpStatusCode[EHttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
151
|
-
EHttpStatusCode[EHttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
152
|
-
EHttpStatusCode[EHttpStatusCode["Locked"] = 423] = "Locked";
|
|
153
|
-
EHttpStatusCode[EHttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
|
|
154
|
-
EHttpStatusCode[EHttpStatusCode["TooEarly"] = 425] = "TooEarly";
|
|
155
|
-
EHttpStatusCode[EHttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
156
|
-
EHttpStatusCode[EHttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
157
|
-
EHttpStatusCode[EHttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
158
|
-
EHttpStatusCode[EHttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
159
|
-
EHttpStatusCode[EHttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
160
|
-
EHttpStatusCode[EHttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
|
|
161
|
-
EHttpStatusCode[EHttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
|
|
162
|
-
EHttpStatusCode[EHttpStatusCode["BadGateway"] = 502] = "BadGateway";
|
|
163
|
-
EHttpStatusCode[EHttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
164
|
-
EHttpStatusCode[EHttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
165
|
-
EHttpStatusCode[EHttpStatusCode["HTTPVersionNotSupported"] = 505] = "HTTPVersionNotSupported";
|
|
166
|
-
EHttpStatusCode[EHttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
167
|
-
EHttpStatusCode[EHttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
168
|
-
EHttpStatusCode[EHttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
169
|
-
EHttpStatusCode[EHttpStatusCode["NotExtended"] = 510] = "NotExtended";
|
|
170
|
-
EHttpStatusCode[EHttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
171
|
-
})(EHttpStatusCode || (EHttpStatusCode = {}));
|
|
172
|
-
|
|
173
|
-
({
|
|
174
|
-
GET: EHttpStatusCode.OK,
|
|
175
|
-
POST: EHttpStatusCode.Created,
|
|
176
|
-
PUT: EHttpStatusCode.Created,
|
|
177
|
-
PATCH: EHttpStatusCode.Accepted,
|
|
178
|
-
DELETE: EHttpStatusCode.Accepted,
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
class HttpError extends Error {
|
|
182
|
-
constructor(code = 500, _body = '') {
|
|
183
|
-
super(typeof _body === 'string' ? _body : _body.message);
|
|
184
|
-
this.code = code;
|
|
185
|
-
this._body = _body;
|
|
186
|
-
}
|
|
187
|
-
get body() {
|
|
188
|
-
return typeof this._body === 'string' ? {
|
|
189
|
-
statusCode: this.code,
|
|
190
|
-
message: this.message,
|
|
191
|
-
error: httpStatusCodes[this.code],
|
|
192
|
-
} : Object.assign(Object.assign({}, this._body), { statusCode: this.code, message: this.message, error: httpStatusCodes[this.code] });
|
|
193
|
-
}
|
|
194
|
-
attachRenderer(renderer) {
|
|
195
|
-
this.renderer = renderer;
|
|
196
|
-
}
|
|
197
|
-
getRenderer() {
|
|
198
|
-
return this.renderer;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
33
|
const METADATA_WORKSPACE = 'moost';
|
|
203
34
|
const moostMate = new mate.Mate(METADATA_WORKSPACE, {
|
|
204
35
|
readType: true,
|
|
@@ -405,7 +236,7 @@ function bindControllerMethods(options) {
|
|
|
405
236
|
const interceptorMeta = mate.read(handler);
|
|
406
237
|
if (interceptorMeta === null || interceptorMeta === void 0 ? void 0 : interceptorMeta.injectable) {
|
|
407
238
|
interceptorHandlers.push((...args) => __awaiter(this, void 0, void 0, function* () {
|
|
408
|
-
const { restoreCtx } =
|
|
239
|
+
const { restoreCtx } = eventCore.useEventContext();
|
|
409
240
|
const targetInstance = yield getInstance();
|
|
410
241
|
restoreCtx();
|
|
411
242
|
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.silent))(...args);
|
|
@@ -861,17 +692,6 @@ class Moost {
|
|
|
861
692
|
}
|
|
862
693
|
}
|
|
863
694
|
|
|
864
|
-
function useControllerMeta() {
|
|
865
|
-
const moostStore = useMoostStore();
|
|
866
|
-
return {
|
|
867
|
-
getClassMeta: () => getMoostMate().read(moostStore.value.controller),
|
|
868
|
-
getMethodMeta: () => getMoostMate().read(moostStore.value.controller, moostStore.value.method),
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
function useMoostStore() {
|
|
872
|
-
return useHttpContext().store('moost');
|
|
873
|
-
}
|
|
874
|
-
|
|
875
695
|
const genericTypesCastPipe = (strict) => {
|
|
876
696
|
const handler = (value, { paramMeta: meta }) => {
|
|
877
697
|
if (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
@@ -928,7 +748,7 @@ const genericTypesCastPipe = (strict) => {
|
|
|
928
748
|
};
|
|
929
749
|
function typeError(value, targetType, label) {
|
|
930
750
|
const prefix = label ? `Argument "${label}" with value ` : '';
|
|
931
|
-
throw new
|
|
751
|
+
throw new Error(`${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
|
|
932
752
|
}
|
|
933
753
|
|
|
934
754
|
const DEFAULT_ERROR_LIMIT = 10;
|
|
@@ -1004,5 +824,4 @@ exports.getMoostInfact = getMoostInfact;
|
|
|
1004
824
|
exports.getMoostMate = getMoostMate;
|
|
1005
825
|
exports.getNewMoostInfact = getNewMoostInfact;
|
|
1006
826
|
exports.resolvePipe = resolvePipe;
|
|
1007
|
-
exports.useControllerMeta = useControllerMeta;
|
|
1008
827
|
exports.validatePipe = validatePipe;
|
package/dist/index.d.ts
CHANGED
|
@@ -328,11 +328,6 @@ declare interface TValidatePipeOptions {
|
|
|
328
328
|
errorCb?: (message: string, details: string | TObject) => unknown;
|
|
329
329
|
}
|
|
330
330
|
|
|
331
|
-
export declare function useControllerMeta<T extends TMoostMetadata = TMoostMetadata>(): {
|
|
332
|
-
getClassMeta: () => T | undefined;
|
|
333
|
-
getMethodMeta: () => T | undefined;
|
|
334
|
-
};
|
|
335
|
-
|
|
336
331
|
export declare function Validate<T = unknown>(validator: TValidoFn<T>): PropertyDecorator & ParameterDecorator;
|
|
337
332
|
|
|
338
333
|
export declare const validatePipe: (opts?: TValidatePipeOptions) => TPipeFn;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { useEventContext, useEventId, useRouteParams } from '@wooksjs/event-core';
|
|
2
|
-
import 'url';
|
|
3
|
-
import 'stream';
|
|
4
|
-
import 'wooks';
|
|
5
|
-
import 'http';
|
|
6
1
|
import { Mate, getConstructor, isConstructor } from '@prostojs/mate';
|
|
7
2
|
import { Infact, createProvideRegistry } from '@prostojs/infact';
|
|
3
|
+
import { useEventId, useEventContext, useRouteParams } from '@wooksjs/event-core';
|
|
8
4
|
import { validoIsTypeOf, validoIsString, validoIsNumber, validoIsBoolean, Valido } from '@prostojs/valido';
|
|
9
5
|
|
|
10
6
|
/******************************************************************************
|
|
@@ -32,171 +28,6 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
32
28
|
});
|
|
33
29
|
}
|
|
34
30
|
|
|
35
|
-
function useHttpContext() {
|
|
36
|
-
return useEventContext('HTTP');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const httpStatusCodes = {
|
|
40
|
-
[100]: 'Continue',
|
|
41
|
-
[101]: 'Switching protocols',
|
|
42
|
-
[102]: 'Processing',
|
|
43
|
-
[103]: 'Early Hints',
|
|
44
|
-
[200]: 'OK',
|
|
45
|
-
[201]: 'Created',
|
|
46
|
-
[202]: 'Accepted',
|
|
47
|
-
[203]: 'Non-Authoritative Information',
|
|
48
|
-
[204]: 'No Content',
|
|
49
|
-
[205]: 'Reset Content',
|
|
50
|
-
[206]: 'Partial Content',
|
|
51
|
-
[207]: 'Multi-Status',
|
|
52
|
-
[208]: 'Already Reported',
|
|
53
|
-
[226]: 'IM Used',
|
|
54
|
-
[300]: 'Multiple Choices',
|
|
55
|
-
[301]: 'Moved Permanently',
|
|
56
|
-
[302]: 'Found (Previously "Moved Temporarily")',
|
|
57
|
-
[303]: 'See Other',
|
|
58
|
-
[304]: 'Not Modified',
|
|
59
|
-
[305]: 'Use Proxy',
|
|
60
|
-
[306]: 'Switch Proxy',
|
|
61
|
-
[307]: 'Temporary Redirect',
|
|
62
|
-
[308]: 'Permanent Redirect',
|
|
63
|
-
[400]: 'Bad Request',
|
|
64
|
-
[401]: 'Unauthorized',
|
|
65
|
-
[402]: 'Payment Required',
|
|
66
|
-
[403]: 'Forbidden',
|
|
67
|
-
[404]: 'Not Found',
|
|
68
|
-
[405]: 'Method Not Allowed',
|
|
69
|
-
[406]: 'Not Acceptable',
|
|
70
|
-
[407]: 'Proxy Authentication Required',
|
|
71
|
-
[408]: 'Request Timeout',
|
|
72
|
-
[409]: 'Conflict',
|
|
73
|
-
[410]: 'Gone',
|
|
74
|
-
[411]: 'Length Required',
|
|
75
|
-
[412]: 'Precondition Failed',
|
|
76
|
-
[413]: 'Payload Too Large',
|
|
77
|
-
[414]: 'URI Too Long',
|
|
78
|
-
[415]: 'Unsupported Media Type',
|
|
79
|
-
[416]: 'Range Not Satisfiable',
|
|
80
|
-
[417]: 'Expectation Failed',
|
|
81
|
-
[418]: 'I\'m a Teapot',
|
|
82
|
-
[421]: 'Misdirected Request',
|
|
83
|
-
[422]: 'Unprocessable Entity',
|
|
84
|
-
[423]: 'Locked',
|
|
85
|
-
[424]: 'Failed Dependency',
|
|
86
|
-
[425]: 'Too Early',
|
|
87
|
-
[426]: 'Upgrade Required',
|
|
88
|
-
[428]: 'Precondition Required',
|
|
89
|
-
[429]: 'Too Many Requests',
|
|
90
|
-
[431]: 'Request Header Fields Too Large',
|
|
91
|
-
[451]: 'Unavailable For Legal Reasons',
|
|
92
|
-
[500]: 'Internal Server Error',
|
|
93
|
-
[501]: 'Not Implemented',
|
|
94
|
-
[502]: 'Bad Gateway',
|
|
95
|
-
[503]: 'Service Unavailable',
|
|
96
|
-
[504]: 'Gateway Timeout',
|
|
97
|
-
[505]: 'HTTP Version Not Supported',
|
|
98
|
-
[506]: 'Variant Also Negotiates',
|
|
99
|
-
[507]: 'Insufficient Storage',
|
|
100
|
-
[508]: 'Loop Detected',
|
|
101
|
-
[510]: 'Not Extended',
|
|
102
|
-
[511]: 'Network Authentication Required',
|
|
103
|
-
};
|
|
104
|
-
var EHttpStatusCode;
|
|
105
|
-
(function (EHttpStatusCode) {
|
|
106
|
-
EHttpStatusCode[EHttpStatusCode["Continue"] = 100] = "Continue";
|
|
107
|
-
EHttpStatusCode[EHttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
|
|
108
|
-
EHttpStatusCode[EHttpStatusCode["Processing"] = 102] = "Processing";
|
|
109
|
-
EHttpStatusCode[EHttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
|
|
110
|
-
EHttpStatusCode[EHttpStatusCode["OK"] = 200] = "OK";
|
|
111
|
-
EHttpStatusCode[EHttpStatusCode["Created"] = 201] = "Created";
|
|
112
|
-
EHttpStatusCode[EHttpStatusCode["Accepted"] = 202] = "Accepted";
|
|
113
|
-
EHttpStatusCode[EHttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
|
|
114
|
-
EHttpStatusCode[EHttpStatusCode["NoContent"] = 204] = "NoContent";
|
|
115
|
-
EHttpStatusCode[EHttpStatusCode["ResetContent"] = 205] = "ResetContent";
|
|
116
|
-
EHttpStatusCode[EHttpStatusCode["PartialContent"] = 206] = "PartialContent";
|
|
117
|
-
EHttpStatusCode[EHttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
|
|
118
|
-
EHttpStatusCode[EHttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
|
|
119
|
-
EHttpStatusCode[EHttpStatusCode["IMUsed"] = 226] = "IMUsed";
|
|
120
|
-
EHttpStatusCode[EHttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
|
|
121
|
-
EHttpStatusCode[EHttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
|
|
122
|
-
EHttpStatusCode[EHttpStatusCode["Found"] = 302] = "Found";
|
|
123
|
-
EHttpStatusCode[EHttpStatusCode["SeeOther"] = 303] = "SeeOther";
|
|
124
|
-
EHttpStatusCode[EHttpStatusCode["NotModified"] = 304] = "NotModified";
|
|
125
|
-
EHttpStatusCode[EHttpStatusCode["UseProxy"] = 305] = "UseProxy";
|
|
126
|
-
EHttpStatusCode[EHttpStatusCode["SwitchProxy"] = 306] = "SwitchProxy";
|
|
127
|
-
EHttpStatusCode[EHttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
128
|
-
EHttpStatusCode[EHttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
129
|
-
EHttpStatusCode[EHttpStatusCode["BadRequest"] = 400] = "BadRequest";
|
|
130
|
-
EHttpStatusCode[EHttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
|
|
131
|
-
EHttpStatusCode[EHttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
|
|
132
|
-
EHttpStatusCode[EHttpStatusCode["Forbidden"] = 403] = "Forbidden";
|
|
133
|
-
EHttpStatusCode[EHttpStatusCode["NotFound"] = 404] = "NotFound";
|
|
134
|
-
EHttpStatusCode[EHttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
135
|
-
EHttpStatusCode[EHttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
|
|
136
|
-
EHttpStatusCode[EHttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
137
|
-
EHttpStatusCode[EHttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
|
|
138
|
-
EHttpStatusCode[EHttpStatusCode["Conflict"] = 409] = "Conflict";
|
|
139
|
-
EHttpStatusCode[EHttpStatusCode["Gone"] = 410] = "Gone";
|
|
140
|
-
EHttpStatusCode[EHttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
|
|
141
|
-
EHttpStatusCode[EHttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
|
|
142
|
-
EHttpStatusCode[EHttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
|
|
143
|
-
EHttpStatusCode[EHttpStatusCode["URITooLong"] = 414] = "URITooLong";
|
|
144
|
-
EHttpStatusCode[EHttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
|
|
145
|
-
EHttpStatusCode[EHttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
|
|
146
|
-
EHttpStatusCode[EHttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
|
|
147
|
-
EHttpStatusCode[EHttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
|
|
148
|
-
EHttpStatusCode[EHttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
|
|
149
|
-
EHttpStatusCode[EHttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
|
|
150
|
-
EHttpStatusCode[EHttpStatusCode["Locked"] = 423] = "Locked";
|
|
151
|
-
EHttpStatusCode[EHttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
|
|
152
|
-
EHttpStatusCode[EHttpStatusCode["TooEarly"] = 425] = "TooEarly";
|
|
153
|
-
EHttpStatusCode[EHttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
|
|
154
|
-
EHttpStatusCode[EHttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
|
|
155
|
-
EHttpStatusCode[EHttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
|
|
156
|
-
EHttpStatusCode[EHttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
|
|
157
|
-
EHttpStatusCode[EHttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
|
|
158
|
-
EHttpStatusCode[EHttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
|
|
159
|
-
EHttpStatusCode[EHttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
|
|
160
|
-
EHttpStatusCode[EHttpStatusCode["BadGateway"] = 502] = "BadGateway";
|
|
161
|
-
EHttpStatusCode[EHttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
162
|
-
EHttpStatusCode[EHttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
163
|
-
EHttpStatusCode[EHttpStatusCode["HTTPVersionNotSupported"] = 505] = "HTTPVersionNotSupported";
|
|
164
|
-
EHttpStatusCode[EHttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
|
|
165
|
-
EHttpStatusCode[EHttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
|
|
166
|
-
EHttpStatusCode[EHttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
|
|
167
|
-
EHttpStatusCode[EHttpStatusCode["NotExtended"] = 510] = "NotExtended";
|
|
168
|
-
EHttpStatusCode[EHttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
|
|
169
|
-
})(EHttpStatusCode || (EHttpStatusCode = {}));
|
|
170
|
-
|
|
171
|
-
({
|
|
172
|
-
GET: EHttpStatusCode.OK,
|
|
173
|
-
POST: EHttpStatusCode.Created,
|
|
174
|
-
PUT: EHttpStatusCode.Created,
|
|
175
|
-
PATCH: EHttpStatusCode.Accepted,
|
|
176
|
-
DELETE: EHttpStatusCode.Accepted,
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
class HttpError extends Error {
|
|
180
|
-
constructor(code = 500, _body = '') {
|
|
181
|
-
super(typeof _body === 'string' ? _body : _body.message);
|
|
182
|
-
this.code = code;
|
|
183
|
-
this._body = _body;
|
|
184
|
-
}
|
|
185
|
-
get body() {
|
|
186
|
-
return typeof this._body === 'string' ? {
|
|
187
|
-
statusCode: this.code,
|
|
188
|
-
message: this.message,
|
|
189
|
-
error: httpStatusCodes[this.code],
|
|
190
|
-
} : Object.assign(Object.assign({}, this._body), { statusCode: this.code, message: this.message, error: httpStatusCodes[this.code] });
|
|
191
|
-
}
|
|
192
|
-
attachRenderer(renderer) {
|
|
193
|
-
this.renderer = renderer;
|
|
194
|
-
}
|
|
195
|
-
getRenderer() {
|
|
196
|
-
return this.renderer;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
31
|
const METADATA_WORKSPACE = 'moost';
|
|
201
32
|
const moostMate = new Mate(METADATA_WORKSPACE, {
|
|
202
33
|
readType: true,
|
|
@@ -403,7 +234,7 @@ function bindControllerMethods(options) {
|
|
|
403
234
|
const interceptorMeta = mate.read(handler);
|
|
404
235
|
if (interceptorMeta === null || interceptorMeta === void 0 ? void 0 : interceptorMeta.injectable) {
|
|
405
236
|
interceptorHandlers.push((...args) => __awaiter(this, void 0, void 0, function* () {
|
|
406
|
-
const { restoreCtx } =
|
|
237
|
+
const { restoreCtx } = useEventContext();
|
|
407
238
|
const targetInstance = yield getInstance();
|
|
408
239
|
restoreCtx();
|
|
409
240
|
return (yield getCallableFn(targetInstance, handler, restoreCtx, pipes, options.silent))(...args);
|
|
@@ -859,17 +690,6 @@ class Moost {
|
|
|
859
690
|
}
|
|
860
691
|
}
|
|
861
692
|
|
|
862
|
-
function useControllerMeta() {
|
|
863
|
-
const moostStore = useMoostStore();
|
|
864
|
-
return {
|
|
865
|
-
getClassMeta: () => getMoostMate().read(moostStore.value.controller),
|
|
866
|
-
getMethodMeta: () => getMoostMate().read(moostStore.value.controller, moostStore.value.method),
|
|
867
|
-
};
|
|
868
|
-
}
|
|
869
|
-
function useMoostStore() {
|
|
870
|
-
return useHttpContext().store('moost');
|
|
871
|
-
}
|
|
872
|
-
|
|
873
693
|
const genericTypesCastPipe = (strict) => {
|
|
874
694
|
const handler = (value, { paramMeta: meta }) => {
|
|
875
695
|
if (meta === null || meta === void 0 ? void 0 : meta.type) {
|
|
@@ -926,7 +746,7 @@ const genericTypesCastPipe = (strict) => {
|
|
|
926
746
|
};
|
|
927
747
|
function typeError(value, targetType, label) {
|
|
928
748
|
const prefix = label ? `Argument "${label}" with value ` : '';
|
|
929
|
-
throw new
|
|
749
|
+
throw new Error(`${prefix}${JSON.stringify(value)} is not a ${targetType} type`);
|
|
930
750
|
}
|
|
931
751
|
|
|
932
752
|
const DEFAULT_ERROR_LIMIT = 10;
|
|
@@ -972,4 +792,4 @@ const validatePipe = (opts) => {
|
|
|
972
792
|
return pipe;
|
|
973
793
|
};
|
|
974
794
|
|
|
975
|
-
export { Circular, Const, Controller, Dto, Id, ImportController, Inherit, Inject, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostInfact, getMoostMate, getNewMoostInfact, resolvePipe,
|
|
795
|
+
export { Circular, Const, Controller, Dto, Id, ImportController, Inherit, Inject, Injectable, Intercept, InterceptorHandler, IsArray, IsBoolean, IsNumber, IsString, IsTypeOf, Label, Moost, Optional, Param, Params, Provide, Required, Resolve, TInterceptorPriority, TPipePriority, Validate, genericTypesCastPipe, getMoostInfact, getMoostMate, getNewMoostInfact, resolvePipe, validatePipe };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moost",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "moost",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@prostojs/infact": "^0.1.7",
|
|
26
26
|
"@prostojs/mate": "^0.1.13",
|
|
27
27
|
"@prostojs/valido": "^0.0.2",
|
|
28
|
-
"@wooksjs/event-core": "^0.2.
|
|
29
|
-
"wooks": "^0.2.
|
|
28
|
+
"@wooksjs/event-core": "^0.2.9",
|
|
29
|
+
"wooks": "^0.2.9"
|
|
30
30
|
},
|
|
31
31
|
"author": "Artem Maltsev",
|
|
32
32
|
"license": "MIT",
|