@moostjs/event-http 0.2.15 → 0.2.17
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 +19 -318
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +20 -319
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var eventHttp = require('@wooksjs/event-http');
|
|
4
4
|
var moost = require('moost');
|
|
5
|
+
var infact = require('@prostojs/infact');
|
|
5
6
|
var http = require('http');
|
|
6
7
|
var https = require('https');
|
|
7
8
|
var eventCore = require('@wooksjs/event-core');
|
|
@@ -31,19 +32,6 @@ function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
function createProvideRegistry(...args) {
|
|
35
|
-
const provide = {};
|
|
36
|
-
for (const a of args) {
|
|
37
|
-
const [type, fn] = a;
|
|
38
|
-
const key = typeof type === 'string' ? type : Symbol.for(type);
|
|
39
|
-
provide[key] = {
|
|
40
|
-
fn,
|
|
41
|
-
resolved: false,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return provide;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
35
|
class MoostHttp {
|
|
48
36
|
constructor(httpApp) {
|
|
49
37
|
this.pathBuilders = {};
|
|
@@ -67,7 +55,7 @@ class MoostHttp {
|
|
|
67
55
|
return this.httpApp.listen(...args);
|
|
68
56
|
}
|
|
69
57
|
getProvideRegistry() {
|
|
70
|
-
return createProvideRegistry([eventHttp.WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
|
|
58
|
+
return infact.createProvideRegistry([eventHttp.WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [http.Server, () => this.getHttpApp().getServer()], [https.Server, () => this.getHttpApp().getServer()]);
|
|
71
59
|
}
|
|
72
60
|
bindHandler(opts) {
|
|
73
61
|
let fn;
|
|
@@ -93,7 +81,12 @@ class MoostHttp {
|
|
|
93
81
|
let response;
|
|
94
82
|
const interceptorHandler = yield opts.getIterceptorHandler();
|
|
95
83
|
restoreCtx();
|
|
96
|
-
|
|
84
|
+
try {
|
|
85
|
+
yield interceptorHandler.init();
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
97
90
|
// params
|
|
98
91
|
let args = [];
|
|
99
92
|
try {
|
|
@@ -179,15 +172,15 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
179
172
|
});
|
|
180
173
|
}
|
|
181
174
|
|
|
182
|
-
const banner
|
|
175
|
+
const banner = () => `[${"@wooksjs/http-body"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
183
176
|
|
|
184
177
|
/* istanbul ignore file */
|
|
185
|
-
function logError
|
|
186
|
-
console.error('[91m' + '[1m' + banner
|
|
178
|
+
function logError(error) {
|
|
179
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
187
180
|
}
|
|
188
181
|
|
|
189
|
-
function panic
|
|
190
|
-
logError
|
|
182
|
+
function panic(error) {
|
|
183
|
+
logError(error);
|
|
191
184
|
return new Error(error);
|
|
192
185
|
}
|
|
193
186
|
|
|
@@ -202,7 +195,7 @@ function uncompressBody(encodings, body) {
|
|
|
202
195
|
let newBody = body;
|
|
203
196
|
for (const e of encodings.reverse()) {
|
|
204
197
|
if (!compressors[e]) {
|
|
205
|
-
throw panic
|
|
198
|
+
throw panic(`Usupported compression type "${e}".`);
|
|
206
199
|
}
|
|
207
200
|
newBody = yield compressors[e].uncompress(body);
|
|
208
201
|
}
|
|
@@ -259,7 +252,7 @@ function useBody() {
|
|
|
259
252
|
return v;
|
|
260
253
|
}
|
|
261
254
|
function formDataParser(v) {
|
|
262
|
-
const boundary = '--' + (/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1];
|
|
255
|
+
const boundary = '--' + ((/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1]);
|
|
263
256
|
if (!boundary)
|
|
264
257
|
throw new eventHttp.HttpError(eventHttp.EHttpStatusCode.BadRequest, 'form-data boundary not recognized');
|
|
265
258
|
const parts = v.trim().split(boundary);
|
|
@@ -551,298 +544,6 @@ function RawBody() {
|
|
|
551
544
|
return moost.Resolve(() => useBody().rawBody(), 'body');
|
|
552
545
|
}
|
|
553
546
|
|
|
554
|
-
function getConstructor(instance) {
|
|
555
|
-
return isConstructor(instance) ?
|
|
556
|
-
instance : instance.constructor ?
|
|
557
|
-
instance.constructor : Object.getPrototypeOf(instance).constructor;
|
|
558
|
-
}
|
|
559
|
-
function isConstructor(v) {
|
|
560
|
-
return typeof v === 'function' && Object.getOwnPropertyNames(v).includes('prototype') && !Object.getOwnPropertyNames(v).includes('caller') && !!v.name;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
const classMetadata = {};
|
|
564
|
-
const paramMetadata = {};
|
|
565
|
-
const root = typeof global === 'object' ? global : typeof self === 'object' ? self : {};
|
|
566
|
-
function getMetaObject(target, prop) {
|
|
567
|
-
const isParam = typeof prop !== 'undefined';
|
|
568
|
-
const metadata = isParam ? paramMetadata : classMetadata;
|
|
569
|
-
const targetKey = Symbol.for(getConstructor(target));
|
|
570
|
-
let meta = metadata[targetKey] = metadata[targetKey] || {};
|
|
571
|
-
if (isParam)
|
|
572
|
-
meta = (meta[prop] = meta[prop] || {});
|
|
573
|
-
return meta;
|
|
574
|
-
}
|
|
575
|
-
const _reflect = {
|
|
576
|
-
getOwnMetadata(key, target, prop) {
|
|
577
|
-
return getMetaObject(target, prop)[key];
|
|
578
|
-
},
|
|
579
|
-
defineMetadata(key, data, target, prop) {
|
|
580
|
-
const meta = getMetaObject(target, prop);
|
|
581
|
-
meta[key] = data;
|
|
582
|
-
},
|
|
583
|
-
metadata(key, data) {
|
|
584
|
-
return ((target, propKey) => {
|
|
585
|
-
Reflect$1.defineMetadata(key, data, target, propKey);
|
|
586
|
-
});
|
|
587
|
-
},
|
|
588
|
-
};
|
|
589
|
-
if (!root.Reflect) {
|
|
590
|
-
root.Reflect = _reflect;
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
const funcs = [
|
|
594
|
-
'getOwnMetadata',
|
|
595
|
-
'defineMetadata',
|
|
596
|
-
'metadata',
|
|
597
|
-
];
|
|
598
|
-
const target = root.Reflect;
|
|
599
|
-
for (const func of funcs) {
|
|
600
|
-
if (typeof target[func] !== 'function') {
|
|
601
|
-
Object.defineProperty(target, func, { configurable: true, writable: true, value: _reflect[func] });
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
const Reflect$1 = _reflect;
|
|
606
|
-
|
|
607
|
-
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
608
|
-
|
|
609
|
-
function logError(error) {
|
|
610
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
function panic(error) {
|
|
614
|
-
logError(error);
|
|
615
|
-
return new Error(error);
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
const Reflect = (global === null || global === void 0 ? void 0 : global.Reflect) || (self === null || self === void 0 ? void 0 : self.Reflect) || Reflect$1;
|
|
619
|
-
class Mate {
|
|
620
|
-
constructor(workspace, options = {}) {
|
|
621
|
-
this.workspace = workspace;
|
|
622
|
-
this.options = options;
|
|
623
|
-
}
|
|
624
|
-
set(args, key, value, isArray) {
|
|
625
|
-
var _a;
|
|
626
|
-
let level = 'CLASS';
|
|
627
|
-
const newArgs = args.level === 'CLASS' ? { target: args.target }
|
|
628
|
-
: args.level === 'PROP' ? { target: args.target, propKey: args.propKey }
|
|
629
|
-
: args;
|
|
630
|
-
let meta = Reflect.getOwnMetadata(this.workspace, newArgs.target, newArgs.propKey) || {};
|
|
631
|
-
if (newArgs.propKey && this.options.readReturnType && !meta.returnType && args.descriptor) {
|
|
632
|
-
meta.returnType = Reflect.getOwnMetadata('design:returntype', newArgs.target, newArgs.propKey);
|
|
633
|
-
}
|
|
634
|
-
if (newArgs.propKey && this.options.readType && !meta.type) {
|
|
635
|
-
meta.type = Reflect.getOwnMetadata('design:type', newArgs.target, newArgs.propKey);
|
|
636
|
-
}
|
|
637
|
-
const { index } = newArgs;
|
|
638
|
-
const cb = typeof key === 'function' ? key : undefined;
|
|
639
|
-
let data = meta;
|
|
640
|
-
if (!data.params) {
|
|
641
|
-
data.params = (_a = Reflect.getOwnMetadata('design:paramtypes', newArgs.target, newArgs.propKey)) === null || _a === void 0 ? void 0 : _a.map((f) => ({ type: f }));
|
|
642
|
-
}
|
|
643
|
-
if (typeof index === 'number') {
|
|
644
|
-
level = 'PARAM';
|
|
645
|
-
data.params = data.params || [];
|
|
646
|
-
data.params[index] = data.params[index] || {
|
|
647
|
-
type: undefined,
|
|
648
|
-
};
|
|
649
|
-
if (cb) {
|
|
650
|
-
data.params[index] = cb(data.params[index], level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
|
|
651
|
-
}
|
|
652
|
-
else {
|
|
653
|
-
data = data.params[index];
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
else if (!index && !args.descriptor && args.propKey && this.options.collectPropKeys && args.level !== 'CLASS') {
|
|
657
|
-
this.set({ ...args, level: 'CLASS' }, (meta) => {
|
|
658
|
-
if (!meta.properties) {
|
|
659
|
-
meta.properties = [args.propKey];
|
|
660
|
-
}
|
|
661
|
-
else if (!meta.properties.includes(args.propKey)) {
|
|
662
|
-
meta.properties.push(args.propKey);
|
|
663
|
-
}
|
|
664
|
-
return meta;
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
level = typeof index === 'number' ? 'PARAM' : newArgs.propKey && newArgs.descriptor ? 'METHOD' : newArgs.propKey ? 'PROP' : 'CLASS';
|
|
668
|
-
if (typeof key !== 'function') {
|
|
669
|
-
if (isArray) {
|
|
670
|
-
const newArray = (data[key] || []);
|
|
671
|
-
if (!Array.isArray(newArray)) {
|
|
672
|
-
panic('Mate.add (isArray=true) called for non-array metadata');
|
|
673
|
-
}
|
|
674
|
-
newArray.unshift(value);
|
|
675
|
-
data[key] = newArray;
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
data[key] = value;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
else if (cb && typeof index !== 'number') {
|
|
682
|
-
meta = cb(data, level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
|
|
683
|
-
}
|
|
684
|
-
Reflect.defineMetadata(this.workspace, meta, newArgs.target, newArgs.propKey);
|
|
685
|
-
}
|
|
686
|
-
read(target, propKey) {
|
|
687
|
-
const isConstr = isConstructor(target);
|
|
688
|
-
const constructor = isConstr ? target : getConstructor(target);
|
|
689
|
-
const proto = constructor.prototype;
|
|
690
|
-
let ownMeta = Reflect.getOwnMetadata(this.workspace, typeof propKey === 'string' ? proto : constructor, propKey);
|
|
691
|
-
if (this.options.inherit) {
|
|
692
|
-
const inheritFn = typeof this.options.inherit === 'function' ? this.options.inherit : undefined;
|
|
693
|
-
let shouldInherit = this.options.inherit;
|
|
694
|
-
if (inheritFn) {
|
|
695
|
-
if (typeof propKey === 'string') {
|
|
696
|
-
const classMeta = Reflect.getOwnMetadata(this.workspace, constructor);
|
|
697
|
-
shouldInherit = inheritFn(classMeta, ownMeta, 'PROP', propKey);
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
shouldInherit = inheritFn(ownMeta, ownMeta, 'CLASS');
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
if (shouldInherit) {
|
|
704
|
-
const parent = Object.getPrototypeOf(constructor);
|
|
705
|
-
if (typeof parent === 'function' && parent !== fnProto && parent !== constructor) {
|
|
706
|
-
const inheritedMeta = this.read(parent, propKey) || {};
|
|
707
|
-
const ownParams = ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params;
|
|
708
|
-
ownMeta = { ...inheritedMeta, ...ownMeta };
|
|
709
|
-
if (typeof propKey === 'string' && ownParams && (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params)) {
|
|
710
|
-
for (let i = 0; i < ownParams.length; i++) {
|
|
711
|
-
if (typeof (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i]) !== 'undefined') {
|
|
712
|
-
const ownParam = ownParams[i];
|
|
713
|
-
if (ownMeta.params && inheritFn && inheritFn(ownMeta, ownParam, 'PARAM', typeof propKey === 'string' ? propKey : undefined)) {
|
|
714
|
-
ownMeta.params[i] = {
|
|
715
|
-
...inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i],
|
|
716
|
-
...ownParams[i],
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
return ownMeta;
|
|
726
|
-
}
|
|
727
|
-
apply(...decorators) {
|
|
728
|
-
return ((target, propKey, descriptor) => {
|
|
729
|
-
for (const d of decorators) {
|
|
730
|
-
d(target, propKey, descriptor);
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
decorate(key, value, isArray, level) {
|
|
735
|
-
return ((target, propKey, descriptor) => {
|
|
736
|
-
const args = {
|
|
737
|
-
target,
|
|
738
|
-
propKey,
|
|
739
|
-
descriptor: typeof descriptor === 'number' ? undefined : descriptor,
|
|
740
|
-
index: typeof descriptor === 'number' ? descriptor : undefined,
|
|
741
|
-
level,
|
|
742
|
-
};
|
|
743
|
-
this.set(args, key, value, isArray);
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
|
-
decorateConditional(ccb) {
|
|
747
|
-
return ((target, propKey, descriptor) => {
|
|
748
|
-
const hasIndex = typeof descriptor === 'number';
|
|
749
|
-
const decoratorLevel = hasIndex ? 'PARAM' : propKey && descriptor ? 'METHOD' : propKey ? 'PROP' : 'CLASS';
|
|
750
|
-
const d = ccb(decoratorLevel);
|
|
751
|
-
if (d) {
|
|
752
|
-
d(target, propKey, descriptor);
|
|
753
|
-
}
|
|
754
|
-
});
|
|
755
|
-
}
|
|
756
|
-
decorateClass(key, value, isArray) {
|
|
757
|
-
return this.decorate(key, value, isArray, 'CLASS');
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
const fnProto = Object.getPrototypeOf(Function);
|
|
761
|
-
|
|
762
|
-
const METADATA_WORKSPACE = 'moost';
|
|
763
|
-
const moostMate = new Mate(METADATA_WORKSPACE, {
|
|
764
|
-
readType: true,
|
|
765
|
-
readReturnType: true,
|
|
766
|
-
collectPropKeys: true,
|
|
767
|
-
inherit(classMeta, targetMeta, level) {
|
|
768
|
-
if (level === 'CLASS') {
|
|
769
|
-
return !!(classMeta === null || classMeta === void 0 ? void 0 : classMeta.inherit);
|
|
770
|
-
}
|
|
771
|
-
if (level === 'PROP') {
|
|
772
|
-
return !!(targetMeta === null || targetMeta === void 0 ? void 0 : targetMeta.inherit) || !!((classMeta === null || classMeta === void 0 ? void 0 : classMeta.inherit) && !targetMeta);
|
|
773
|
-
}
|
|
774
|
-
return !!(targetMeta === null || targetMeta === void 0 ? void 0 : targetMeta.inherit);
|
|
775
|
-
},
|
|
776
|
-
});
|
|
777
|
-
function getMoostMate() {
|
|
778
|
-
return moostMate;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
getMoostMate().decorate((meta) => {
|
|
782
|
-
if (!meta.injectable)
|
|
783
|
-
meta.injectable = true;
|
|
784
|
-
return meta;
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
var TInterceptorPriority;
|
|
788
|
-
(function (TInterceptorPriority) {
|
|
789
|
-
TInterceptorPriority[TInterceptorPriority["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
790
|
-
TInterceptorPriority[TInterceptorPriority["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
791
|
-
TInterceptorPriority[TInterceptorPriority["GUARD"] = 2] = "GUARD";
|
|
792
|
-
TInterceptorPriority[TInterceptorPriority["AFTER_GUARD"] = 3] = "AFTER_GUARD";
|
|
793
|
-
TInterceptorPriority[TInterceptorPriority["INTERCEPTOR"] = 4] = "INTERCEPTOR";
|
|
794
|
-
TInterceptorPriority[TInterceptorPriority["CATCH_ERROR"] = 5] = "CATCH_ERROR";
|
|
795
|
-
TInterceptorPriority[TInterceptorPriority["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
796
|
-
})(TInterceptorPriority || (TInterceptorPriority = {}));
|
|
797
|
-
function Intercept(handler, priority) {
|
|
798
|
-
return getMoostMate().decorate('interceptors', {
|
|
799
|
-
handler,
|
|
800
|
-
priority: priority || handler.priority || TInterceptorPriority.INTERCEPTOR,
|
|
801
|
-
}, true);
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
var TPipePriority;
|
|
805
|
-
(function (TPipePriority) {
|
|
806
|
-
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
807
|
-
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
808
|
-
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
809
|
-
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
810
|
-
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
811
|
-
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
812
|
-
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
813
|
-
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
814
|
-
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
815
|
-
})(TPipePriority || (TPipePriority = {}));
|
|
816
|
-
|
|
817
|
-
const resolvePipe = (_value, metas, level) => {
|
|
818
|
-
var _a, _b, _c, _d;
|
|
819
|
-
let resolver;
|
|
820
|
-
if (level === 'PARAM') {
|
|
821
|
-
resolver = (_a = metas.paramMeta) === null || _a === void 0 ? void 0 : _a.resolver;
|
|
822
|
-
}
|
|
823
|
-
else if (level === 'PROP') {
|
|
824
|
-
resolver = (_b = metas.propMeta) === null || _b === void 0 ? void 0 : _b.resolver;
|
|
825
|
-
}
|
|
826
|
-
else if (level === 'METHOD') {
|
|
827
|
-
resolver = (_c = metas.methodMeta) === null || _c === void 0 ? void 0 : _c.resolver;
|
|
828
|
-
}
|
|
829
|
-
else if (level === 'CLASS') {
|
|
830
|
-
resolver = (_d = metas.classMeta) === null || _d === void 0 ? void 0 : _d.resolver;
|
|
831
|
-
}
|
|
832
|
-
if (resolver) {
|
|
833
|
-
return resolver(metas, level);
|
|
834
|
-
}
|
|
835
|
-
return undefined;
|
|
836
|
-
};
|
|
837
|
-
resolvePipe.priority = TPipePriority.RESOLVE;
|
|
838
|
-
|
|
839
|
-
[
|
|
840
|
-
{
|
|
841
|
-
handler: resolvePipe,
|
|
842
|
-
priority: TPipePriority.RESOLVE,
|
|
843
|
-
},
|
|
844
|
-
];
|
|
845
|
-
|
|
846
547
|
const setHeaderInterceptor = (name, value, opts) => {
|
|
847
548
|
const fn = (before, after) => {
|
|
848
549
|
const h = eventHttp.useSetHeader(name);
|
|
@@ -853,11 +554,11 @@ const setHeaderInterceptor = (name, value, opts) => {
|
|
|
853
554
|
}
|
|
854
555
|
});
|
|
855
556
|
};
|
|
856
|
-
fn.priority = TInterceptorPriority.AFTER_ALL;
|
|
557
|
+
fn.priority = moost.TInterceptorPriority.AFTER_ALL;
|
|
857
558
|
return fn;
|
|
858
559
|
};
|
|
859
560
|
function SetHeader(...args) {
|
|
860
|
-
return Intercept(setHeaderInterceptor(...args));
|
|
561
|
+
return moost.Intercept(setHeaderInterceptor(...args));
|
|
861
562
|
}
|
|
862
563
|
const setCookieInterceptor = (name, value, attrs) => {
|
|
863
564
|
const fn = (before, after) => {
|
|
@@ -868,11 +569,11 @@ const setCookieInterceptor = (name, value, attrs) => {
|
|
|
868
569
|
}
|
|
869
570
|
});
|
|
870
571
|
};
|
|
871
|
-
fn.priority = TInterceptorPriority.AFTER_ALL;
|
|
572
|
+
fn.priority = moost.TInterceptorPriority.AFTER_ALL;
|
|
872
573
|
return fn;
|
|
873
574
|
};
|
|
874
575
|
function SetCookie(...args) {
|
|
875
|
-
return Intercept(setCookieInterceptor(...args));
|
|
576
|
+
return moost.Intercept(setCookieInterceptor(...args));
|
|
876
577
|
}
|
|
877
578
|
|
|
878
579
|
function httpValidatePipe(opts) {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { IncomingMessage } from 'http';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
5
|
import { TCookieAttributesInput } from '@wooksjs/event-http';
|
|
6
|
-
import { TInterceptorFn } from '
|
|
6
|
+
import { TInterceptorFn } from 'moost';
|
|
7
7
|
import { TMoostAdapter } from 'moost';
|
|
8
8
|
import { TMoostAdapterOptions } from 'moost';
|
|
9
9
|
import { TPipeFn } from 'moost';
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { WooksHttp, createHttpApp, useHttpContext, useRequest, useHeaders, HttpError, EHttpStatusCode, WooksURLSearchParams, useStatus, useSetHeader, useSetCookie, useAuthorization, useCookies, useSearchParams, useResponse, useSetCookies } from '@wooksjs/event-http';
|
|
2
|
-
import { getMoostMate
|
|
3
|
-
import {
|
|
4
|
-
import { Server } from '
|
|
2
|
+
import { getMoostMate, Resolve, Intercept, TInterceptorPriority, validatePipe } from 'moost';
|
|
3
|
+
import { createProvideRegistry } from '@prostojs/infact';
|
|
4
|
+
import { Server } from 'http';
|
|
5
|
+
import { Server as Server$1 } from 'https';
|
|
5
6
|
import { attachHook } from '@wooksjs/event-core';
|
|
6
7
|
|
|
7
8
|
/******************************************************************************
|
|
@@ -29,19 +30,6 @@ function __awaiter$1(thisArg, _arguments, P, generator) {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
function createProvideRegistry(...args) {
|
|
33
|
-
const provide = {};
|
|
34
|
-
for (const a of args) {
|
|
35
|
-
const [type, fn] = a;
|
|
36
|
-
const key = typeof type === 'string' ? type : Symbol.for(type);
|
|
37
|
-
provide[key] = {
|
|
38
|
-
fn,
|
|
39
|
-
resolved: false,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
return provide;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
33
|
class MoostHttp {
|
|
46
34
|
constructor(httpApp) {
|
|
47
35
|
this.pathBuilders = {};
|
|
@@ -65,7 +53,7 @@ class MoostHttp {
|
|
|
65
53
|
return this.httpApp.listen(...args);
|
|
66
54
|
}
|
|
67
55
|
getProvideRegistry() {
|
|
68
|
-
return createProvideRegistry([WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [Server
|
|
56
|
+
return createProvideRegistry([WooksHttp, () => this.getHttpApp()], ['WooksHttp', () => this.getHttpApp()], [Server, () => this.getHttpApp().getServer()], [Server$1, () => this.getHttpApp().getServer()]);
|
|
69
57
|
}
|
|
70
58
|
bindHandler(opts) {
|
|
71
59
|
let fn;
|
|
@@ -91,7 +79,12 @@ class MoostHttp {
|
|
|
91
79
|
let response;
|
|
92
80
|
const interceptorHandler = yield opts.getIterceptorHandler();
|
|
93
81
|
restoreCtx();
|
|
94
|
-
|
|
82
|
+
try {
|
|
83
|
+
yield interceptorHandler.init();
|
|
84
|
+
}
|
|
85
|
+
catch (e) {
|
|
86
|
+
return e;
|
|
87
|
+
}
|
|
95
88
|
// params
|
|
96
89
|
let args = [];
|
|
97
90
|
try {
|
|
@@ -122,7 +115,7 @@ class MoostHttp {
|
|
|
122
115
|
});
|
|
123
116
|
}
|
|
124
117
|
const pathBuilder = this.httpApp.on(handler.method, targetPath, fn);
|
|
125
|
-
const methodMeta = getMoostMate
|
|
118
|
+
const methodMeta = getMoostMate().read(opts.fakeInstance, opts.method) || {};
|
|
126
119
|
const id = (methodMeta.id || opts.method);
|
|
127
120
|
if (id) {
|
|
128
121
|
const methods = this.pathBuilders[id] = this.pathBuilders[id] || {};
|
|
@@ -143,7 +136,7 @@ class MoostHttp {
|
|
|
143
136
|
}
|
|
144
137
|
|
|
145
138
|
function HttpMethod(method, path) {
|
|
146
|
-
return getMoostMate
|
|
139
|
+
return getMoostMate().decorate('handlers', { method, path, type: 'HTTP' }, true);
|
|
147
140
|
}
|
|
148
141
|
const All = (path) => HttpMethod('*', path);
|
|
149
142
|
const Get = (path) => HttpMethod('GET', path);
|
|
@@ -177,15 +170,15 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
177
170
|
});
|
|
178
171
|
}
|
|
179
172
|
|
|
180
|
-
const banner
|
|
173
|
+
const banner = () => `[${"@wooksjs/http-body"}][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
181
174
|
|
|
182
175
|
/* istanbul ignore file */
|
|
183
|
-
function logError
|
|
184
|
-
console.error('[91m' + '[1m' + banner
|
|
176
|
+
function logError(error) {
|
|
177
|
+
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
185
178
|
}
|
|
186
179
|
|
|
187
|
-
function panic
|
|
188
|
-
logError
|
|
180
|
+
function panic(error) {
|
|
181
|
+
logError(error);
|
|
189
182
|
return new Error(error);
|
|
190
183
|
}
|
|
191
184
|
|
|
@@ -200,7 +193,7 @@ function uncompressBody(encodings, body) {
|
|
|
200
193
|
let newBody = body;
|
|
201
194
|
for (const e of encodings.reverse()) {
|
|
202
195
|
if (!compressors[e]) {
|
|
203
|
-
throw panic
|
|
196
|
+
throw panic(`Usupported compression type "${e}".`);
|
|
204
197
|
}
|
|
205
198
|
newBody = yield compressors[e].uncompress(body);
|
|
206
199
|
}
|
|
@@ -257,7 +250,7 @@ function useBody() {
|
|
|
257
250
|
return v;
|
|
258
251
|
}
|
|
259
252
|
function formDataParser(v) {
|
|
260
|
-
const boundary = '--' + (/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1];
|
|
253
|
+
const boundary = '--' + ((/boundary=([^;]+)(?:;|$)/.exec(contentType || '') || [, ''])[1]);
|
|
261
254
|
if (!boundary)
|
|
262
255
|
throw new HttpError(EHttpStatusCode.BadRequest, 'form-data boundary not recognized');
|
|
263
256
|
const parts = v.trim().split(boundary);
|
|
@@ -549,298 +542,6 @@ function RawBody() {
|
|
|
549
542
|
return Resolve(() => useBody().rawBody(), 'body');
|
|
550
543
|
}
|
|
551
544
|
|
|
552
|
-
function getConstructor(instance) {
|
|
553
|
-
return isConstructor(instance) ?
|
|
554
|
-
instance : instance.constructor ?
|
|
555
|
-
instance.constructor : Object.getPrototypeOf(instance).constructor;
|
|
556
|
-
}
|
|
557
|
-
function isConstructor(v) {
|
|
558
|
-
return typeof v === 'function' && Object.getOwnPropertyNames(v).includes('prototype') && !Object.getOwnPropertyNames(v).includes('caller') && !!v.name;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
const classMetadata = {};
|
|
562
|
-
const paramMetadata = {};
|
|
563
|
-
const root = typeof global === 'object' ? global : typeof self === 'object' ? self : {};
|
|
564
|
-
function getMetaObject(target, prop) {
|
|
565
|
-
const isParam = typeof prop !== 'undefined';
|
|
566
|
-
const metadata = isParam ? paramMetadata : classMetadata;
|
|
567
|
-
const targetKey = Symbol.for(getConstructor(target));
|
|
568
|
-
let meta = metadata[targetKey] = metadata[targetKey] || {};
|
|
569
|
-
if (isParam)
|
|
570
|
-
meta = (meta[prop] = meta[prop] || {});
|
|
571
|
-
return meta;
|
|
572
|
-
}
|
|
573
|
-
const _reflect = {
|
|
574
|
-
getOwnMetadata(key, target, prop) {
|
|
575
|
-
return getMetaObject(target, prop)[key];
|
|
576
|
-
},
|
|
577
|
-
defineMetadata(key, data, target, prop) {
|
|
578
|
-
const meta = getMetaObject(target, prop);
|
|
579
|
-
meta[key] = data;
|
|
580
|
-
},
|
|
581
|
-
metadata(key, data) {
|
|
582
|
-
return ((target, propKey) => {
|
|
583
|
-
Reflect$1.defineMetadata(key, data, target, propKey);
|
|
584
|
-
});
|
|
585
|
-
},
|
|
586
|
-
};
|
|
587
|
-
if (!root.Reflect) {
|
|
588
|
-
root.Reflect = _reflect;
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
const funcs = [
|
|
592
|
-
'getOwnMetadata',
|
|
593
|
-
'defineMetadata',
|
|
594
|
-
'metadata',
|
|
595
|
-
];
|
|
596
|
-
const target = root.Reflect;
|
|
597
|
-
for (const func of funcs) {
|
|
598
|
-
if (typeof target[func] !== 'function') {
|
|
599
|
-
Object.defineProperty(target, func, { configurable: true, writable: true, value: _reflect[func] });
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
const Reflect$1 = _reflect;
|
|
604
|
-
|
|
605
|
-
const banner = () => `[prostojs/mate][${new Date().toISOString().replace('T', ' ').replace(/\.\d{3}z$/i, '')}] `;
|
|
606
|
-
|
|
607
|
-
function logError(error) {
|
|
608
|
-
console.error('[91m' + '[1m' + banner() + error + '[0m');
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
function panic(error) {
|
|
612
|
-
logError(error);
|
|
613
|
-
return new Error(error);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
const Reflect = (global === null || global === void 0 ? void 0 : global.Reflect) || (self === null || self === void 0 ? void 0 : self.Reflect) || Reflect$1;
|
|
617
|
-
class Mate {
|
|
618
|
-
constructor(workspace, options = {}) {
|
|
619
|
-
this.workspace = workspace;
|
|
620
|
-
this.options = options;
|
|
621
|
-
}
|
|
622
|
-
set(args, key, value, isArray) {
|
|
623
|
-
var _a;
|
|
624
|
-
let level = 'CLASS';
|
|
625
|
-
const newArgs = args.level === 'CLASS' ? { target: args.target }
|
|
626
|
-
: args.level === 'PROP' ? { target: args.target, propKey: args.propKey }
|
|
627
|
-
: args;
|
|
628
|
-
let meta = Reflect.getOwnMetadata(this.workspace, newArgs.target, newArgs.propKey) || {};
|
|
629
|
-
if (newArgs.propKey && this.options.readReturnType && !meta.returnType && args.descriptor) {
|
|
630
|
-
meta.returnType = Reflect.getOwnMetadata('design:returntype', newArgs.target, newArgs.propKey);
|
|
631
|
-
}
|
|
632
|
-
if (newArgs.propKey && this.options.readType && !meta.type) {
|
|
633
|
-
meta.type = Reflect.getOwnMetadata('design:type', newArgs.target, newArgs.propKey);
|
|
634
|
-
}
|
|
635
|
-
const { index } = newArgs;
|
|
636
|
-
const cb = typeof key === 'function' ? key : undefined;
|
|
637
|
-
let data = meta;
|
|
638
|
-
if (!data.params) {
|
|
639
|
-
data.params = (_a = Reflect.getOwnMetadata('design:paramtypes', newArgs.target, newArgs.propKey)) === null || _a === void 0 ? void 0 : _a.map((f) => ({ type: f }));
|
|
640
|
-
}
|
|
641
|
-
if (typeof index === 'number') {
|
|
642
|
-
level = 'PARAM';
|
|
643
|
-
data.params = data.params || [];
|
|
644
|
-
data.params[index] = data.params[index] || {
|
|
645
|
-
type: undefined,
|
|
646
|
-
};
|
|
647
|
-
if (cb) {
|
|
648
|
-
data.params[index] = cb(data.params[index], level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
|
|
649
|
-
}
|
|
650
|
-
else {
|
|
651
|
-
data = data.params[index];
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
else if (!index && !args.descriptor && args.propKey && this.options.collectPropKeys && args.level !== 'CLASS') {
|
|
655
|
-
this.set({ ...args, level: 'CLASS' }, (meta) => {
|
|
656
|
-
if (!meta.properties) {
|
|
657
|
-
meta.properties = [args.propKey];
|
|
658
|
-
}
|
|
659
|
-
else if (!meta.properties.includes(args.propKey)) {
|
|
660
|
-
meta.properties.push(args.propKey);
|
|
661
|
-
}
|
|
662
|
-
return meta;
|
|
663
|
-
});
|
|
664
|
-
}
|
|
665
|
-
level = typeof index === 'number' ? 'PARAM' : newArgs.propKey && newArgs.descriptor ? 'METHOD' : newArgs.propKey ? 'PROP' : 'CLASS';
|
|
666
|
-
if (typeof key !== 'function') {
|
|
667
|
-
if (isArray) {
|
|
668
|
-
const newArray = (data[key] || []);
|
|
669
|
-
if (!Array.isArray(newArray)) {
|
|
670
|
-
panic('Mate.add (isArray=true) called for non-array metadata');
|
|
671
|
-
}
|
|
672
|
-
newArray.unshift(value);
|
|
673
|
-
data[key] = newArray;
|
|
674
|
-
}
|
|
675
|
-
else {
|
|
676
|
-
data[key] = value;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
else if (cb && typeof index !== 'number') {
|
|
680
|
-
meta = cb(data, level, args.propKey, typeof args.index === 'number' ? args.index : undefined);
|
|
681
|
-
}
|
|
682
|
-
Reflect.defineMetadata(this.workspace, meta, newArgs.target, newArgs.propKey);
|
|
683
|
-
}
|
|
684
|
-
read(target, propKey) {
|
|
685
|
-
const isConstr = isConstructor(target);
|
|
686
|
-
const constructor = isConstr ? target : getConstructor(target);
|
|
687
|
-
const proto = constructor.prototype;
|
|
688
|
-
let ownMeta = Reflect.getOwnMetadata(this.workspace, typeof propKey === 'string' ? proto : constructor, propKey);
|
|
689
|
-
if (this.options.inherit) {
|
|
690
|
-
const inheritFn = typeof this.options.inherit === 'function' ? this.options.inherit : undefined;
|
|
691
|
-
let shouldInherit = this.options.inherit;
|
|
692
|
-
if (inheritFn) {
|
|
693
|
-
if (typeof propKey === 'string') {
|
|
694
|
-
const classMeta = Reflect.getOwnMetadata(this.workspace, constructor);
|
|
695
|
-
shouldInherit = inheritFn(classMeta, ownMeta, 'PROP', propKey);
|
|
696
|
-
}
|
|
697
|
-
else {
|
|
698
|
-
shouldInherit = inheritFn(ownMeta, ownMeta, 'CLASS');
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (shouldInherit) {
|
|
702
|
-
const parent = Object.getPrototypeOf(constructor);
|
|
703
|
-
if (typeof parent === 'function' && parent !== fnProto && parent !== constructor) {
|
|
704
|
-
const inheritedMeta = this.read(parent, propKey) || {};
|
|
705
|
-
const ownParams = ownMeta === null || ownMeta === void 0 ? void 0 : ownMeta.params;
|
|
706
|
-
ownMeta = { ...inheritedMeta, ...ownMeta };
|
|
707
|
-
if (typeof propKey === 'string' && ownParams && (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params)) {
|
|
708
|
-
for (let i = 0; i < ownParams.length; i++) {
|
|
709
|
-
if (typeof (inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i]) !== 'undefined') {
|
|
710
|
-
const ownParam = ownParams[i];
|
|
711
|
-
if (ownMeta.params && inheritFn && inheritFn(ownMeta, ownParam, 'PARAM', typeof propKey === 'string' ? propKey : undefined)) {
|
|
712
|
-
ownMeta.params[i] = {
|
|
713
|
-
...inheritedMeta === null || inheritedMeta === void 0 ? void 0 : inheritedMeta.params[i],
|
|
714
|
-
...ownParams[i],
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
return ownMeta;
|
|
724
|
-
}
|
|
725
|
-
apply(...decorators) {
|
|
726
|
-
return ((target, propKey, descriptor) => {
|
|
727
|
-
for (const d of decorators) {
|
|
728
|
-
d(target, propKey, descriptor);
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
decorate(key, value, isArray, level) {
|
|
733
|
-
return ((target, propKey, descriptor) => {
|
|
734
|
-
const args = {
|
|
735
|
-
target,
|
|
736
|
-
propKey,
|
|
737
|
-
descriptor: typeof descriptor === 'number' ? undefined : descriptor,
|
|
738
|
-
index: typeof descriptor === 'number' ? descriptor : undefined,
|
|
739
|
-
level,
|
|
740
|
-
};
|
|
741
|
-
this.set(args, key, value, isArray);
|
|
742
|
-
});
|
|
743
|
-
}
|
|
744
|
-
decorateConditional(ccb) {
|
|
745
|
-
return ((target, propKey, descriptor) => {
|
|
746
|
-
const hasIndex = typeof descriptor === 'number';
|
|
747
|
-
const decoratorLevel = hasIndex ? 'PARAM' : propKey && descriptor ? 'METHOD' : propKey ? 'PROP' : 'CLASS';
|
|
748
|
-
const d = ccb(decoratorLevel);
|
|
749
|
-
if (d) {
|
|
750
|
-
d(target, propKey, descriptor);
|
|
751
|
-
}
|
|
752
|
-
});
|
|
753
|
-
}
|
|
754
|
-
decorateClass(key, value, isArray) {
|
|
755
|
-
return this.decorate(key, value, isArray, 'CLASS');
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
const fnProto = Object.getPrototypeOf(Function);
|
|
759
|
-
|
|
760
|
-
const METADATA_WORKSPACE = 'moost';
|
|
761
|
-
const moostMate = new Mate(METADATA_WORKSPACE, {
|
|
762
|
-
readType: true,
|
|
763
|
-
readReturnType: true,
|
|
764
|
-
collectPropKeys: true,
|
|
765
|
-
inherit(classMeta, targetMeta, level) {
|
|
766
|
-
if (level === 'CLASS') {
|
|
767
|
-
return !!(classMeta === null || classMeta === void 0 ? void 0 : classMeta.inherit);
|
|
768
|
-
}
|
|
769
|
-
if (level === 'PROP') {
|
|
770
|
-
return !!(targetMeta === null || targetMeta === void 0 ? void 0 : targetMeta.inherit) || !!((classMeta === null || classMeta === void 0 ? void 0 : classMeta.inherit) && !targetMeta);
|
|
771
|
-
}
|
|
772
|
-
return !!(targetMeta === null || targetMeta === void 0 ? void 0 : targetMeta.inherit);
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
function getMoostMate() {
|
|
776
|
-
return moostMate;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
getMoostMate().decorate((meta) => {
|
|
780
|
-
if (!meta.injectable)
|
|
781
|
-
meta.injectable = true;
|
|
782
|
-
return meta;
|
|
783
|
-
});
|
|
784
|
-
|
|
785
|
-
var TInterceptorPriority;
|
|
786
|
-
(function (TInterceptorPriority) {
|
|
787
|
-
TInterceptorPriority[TInterceptorPriority["BEFORE_ALL"] = 0] = "BEFORE_ALL";
|
|
788
|
-
TInterceptorPriority[TInterceptorPriority["BEFORE_GUARD"] = 1] = "BEFORE_GUARD";
|
|
789
|
-
TInterceptorPriority[TInterceptorPriority["GUARD"] = 2] = "GUARD";
|
|
790
|
-
TInterceptorPriority[TInterceptorPriority["AFTER_GUARD"] = 3] = "AFTER_GUARD";
|
|
791
|
-
TInterceptorPriority[TInterceptorPriority["INTERCEPTOR"] = 4] = "INTERCEPTOR";
|
|
792
|
-
TInterceptorPriority[TInterceptorPriority["CATCH_ERROR"] = 5] = "CATCH_ERROR";
|
|
793
|
-
TInterceptorPriority[TInterceptorPriority["AFTER_ALL"] = 6] = "AFTER_ALL";
|
|
794
|
-
})(TInterceptorPriority || (TInterceptorPriority = {}));
|
|
795
|
-
function Intercept(handler, priority) {
|
|
796
|
-
return getMoostMate().decorate('interceptors', {
|
|
797
|
-
handler,
|
|
798
|
-
priority: priority || handler.priority || TInterceptorPriority.INTERCEPTOR,
|
|
799
|
-
}, true);
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
var TPipePriority;
|
|
803
|
-
(function (TPipePriority) {
|
|
804
|
-
TPipePriority[TPipePriority["BEFORE_RESOLVE"] = 0] = "BEFORE_RESOLVE";
|
|
805
|
-
TPipePriority[TPipePriority["RESOLVE"] = 1] = "RESOLVE";
|
|
806
|
-
TPipePriority[TPipePriority["AFTER_RESOLVE"] = 2] = "AFTER_RESOLVE";
|
|
807
|
-
TPipePriority[TPipePriority["BEFORE_TRANSFORM"] = 3] = "BEFORE_TRANSFORM";
|
|
808
|
-
TPipePriority[TPipePriority["TRANSFORM"] = 4] = "TRANSFORM";
|
|
809
|
-
TPipePriority[TPipePriority["AFTER_TRANSFORM"] = 5] = "AFTER_TRANSFORM";
|
|
810
|
-
TPipePriority[TPipePriority["BEFORE_VALIDATE"] = 6] = "BEFORE_VALIDATE";
|
|
811
|
-
TPipePriority[TPipePriority["VALIDATE"] = 7] = "VALIDATE";
|
|
812
|
-
TPipePriority[TPipePriority["AFTER_VALIDATE"] = 8] = "AFTER_VALIDATE";
|
|
813
|
-
})(TPipePriority || (TPipePriority = {}));
|
|
814
|
-
|
|
815
|
-
const resolvePipe = (_value, metas, level) => {
|
|
816
|
-
var _a, _b, _c, _d;
|
|
817
|
-
let resolver;
|
|
818
|
-
if (level === 'PARAM') {
|
|
819
|
-
resolver = (_a = metas.paramMeta) === null || _a === void 0 ? void 0 : _a.resolver;
|
|
820
|
-
}
|
|
821
|
-
else if (level === 'PROP') {
|
|
822
|
-
resolver = (_b = metas.propMeta) === null || _b === void 0 ? void 0 : _b.resolver;
|
|
823
|
-
}
|
|
824
|
-
else if (level === 'METHOD') {
|
|
825
|
-
resolver = (_c = metas.methodMeta) === null || _c === void 0 ? void 0 : _c.resolver;
|
|
826
|
-
}
|
|
827
|
-
else if (level === 'CLASS') {
|
|
828
|
-
resolver = (_d = metas.classMeta) === null || _d === void 0 ? void 0 : _d.resolver;
|
|
829
|
-
}
|
|
830
|
-
if (resolver) {
|
|
831
|
-
return resolver(metas, level);
|
|
832
|
-
}
|
|
833
|
-
return undefined;
|
|
834
|
-
};
|
|
835
|
-
resolvePipe.priority = TPipePriority.RESOLVE;
|
|
836
|
-
|
|
837
|
-
[
|
|
838
|
-
{
|
|
839
|
-
handler: resolvePipe,
|
|
840
|
-
priority: TPipePriority.RESOLVE,
|
|
841
|
-
},
|
|
842
|
-
];
|
|
843
|
-
|
|
844
545
|
const setHeaderInterceptor = (name, value, opts) => {
|
|
845
546
|
const fn = (before, after) => {
|
|
846
547
|
const h = useSetHeader(name);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-http",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "@moostjs/event-http",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"url": "https://github.com/moostjs/moostjs/issues"
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-http#readme",
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.15",
|
|
32
|
-
"wooks": "^0.2.8",
|
|
33
|
-
"@wooksjs/event-core": "^0.2.8"
|
|
34
|
-
},
|
|
30
|
+
"peerDependencies": {},
|
|
35
31
|
"dependencies": {
|
|
36
|
-
"
|
|
32
|
+
"moost": "0.2.17",
|
|
33
|
+
"@wooksjs/event-core": "^0.2.9",
|
|
34
|
+
"@wooksjs/event-http": "^0.2.9",
|
|
35
|
+
"@prostojs/infact": "^0.1.7",
|
|
36
|
+
"@prostojs/router": ""
|
|
37
37
|
}
|
|
38
38
|
}
|