web_api_base 3.0.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Application.js +81 -7
- package/dist/Application.js.map +1 -1
- package/dist/decorators/controllers/ControllerDecorators.d.ts +22 -18
- package/dist/decorators/controllers/ControllerDecorators.js +66 -50
- package/dist/decorators/controllers/ControllerDecorators.js.map +1 -1
- package/dist/decorators/validations/ValidationDecorators.d.ts +50 -0
- package/dist/decorators/validations/ValidationDecorators.js +181 -0
- package/dist/decorators/validations/ValidationDecorators.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +41 -4
- package/dist/index.js.map +1 -1
- package/dist/metadata/OwnMetaDataContainer.d.ts +12 -0
- package/dist/metadata/OwnMetaDataContainer.js +33 -0
- package/dist/metadata/OwnMetaDataContainer.js.map +1 -0
- package/dist/temp/Application.d.ts +5 -0
- package/dist/temp/Application.js +27 -0
- package/dist/temp/Application.js.map +1 -0
- package/dist/temp/Index.d.ts +1 -0
- package/dist/temp/Index.js +8 -0
- package/dist/temp/Index.js.map +1 -0
- package/dist/temp/controllers/StatusController.d.ts +8 -0
- package/dist/temp/controllers/StatusController.js +58 -0
- package/dist/temp/controllers/StatusController.js.map +1 -0
- package/dist/temp/service/SampleService.d.ts +9 -0
- package/dist/temp/service/SampleService.js +19 -0
- package/dist/temp/service/SampleService.js.map +1 -0
- package/package.json +1 -1
- package/readme.md +223 -7
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
require("reflect-metadata");
|
|
7
|
+
const OwnMetaDataContainer_1 = __importDefault(require("../../metadata/OwnMetaDataContainer"));
|
|
8
|
+
class ValidationDecorators {
|
|
9
|
+
constructor() {
|
|
10
|
+
}
|
|
11
|
+
static AddField(target, property) {
|
|
12
|
+
let meta = this.GetFields(target);
|
|
13
|
+
meta.push(property);
|
|
14
|
+
Reflect.defineMetadata(ValidationDecorators._keysToValidateKeyMetada, meta, target.constructor);
|
|
15
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._keysToValidateKeyMetada, undefined, meta);
|
|
16
|
+
}
|
|
17
|
+
static GetFields(target) {
|
|
18
|
+
var _a;
|
|
19
|
+
let meta = (_a = Reflect.getMetadata(ValidationDecorators._keysToValidateKeyMetada, target)) !== null && _a !== void 0 ? _a : Reflect.getMetadata(ValidationDecorators._keysToValidateKeyMetada, target.constructor);
|
|
20
|
+
if (!meta) {
|
|
21
|
+
let ownMeta = OwnMetaDataContainer_1.default.Get(target, ValidationDecorators._keysToValidateKeyMetada);
|
|
22
|
+
if (ownMeta)
|
|
23
|
+
meta = ownMeta.Value;
|
|
24
|
+
else
|
|
25
|
+
meta = [];
|
|
26
|
+
}
|
|
27
|
+
return meta;
|
|
28
|
+
}
|
|
29
|
+
static Required(message) {
|
|
30
|
+
return function (target, property) {
|
|
31
|
+
ValidationDecorators.AddField(target, property);
|
|
32
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} is required`;
|
|
33
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._requiredKeyMetadata, property, { Message: msg });
|
|
34
|
+
Reflect.defineMetadata(ValidationDecorators._requiredKeyMetadata, { Message: msg }, target, property);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
static IsRequired(target, property) {
|
|
38
|
+
return ValidationDecorators.TryGetValue(target, property, ValidationDecorators._requiredKeyMetadata);
|
|
39
|
+
}
|
|
40
|
+
static MaxLenght(max, message) {
|
|
41
|
+
return function (target, property) {
|
|
42
|
+
ValidationDecorators.AddField(target, property);
|
|
43
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} must be a maximum of ${max} caracteres`;
|
|
44
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._maxlenghtKeyMetadata, property, { Message: msg, Max: max });
|
|
45
|
+
Reflect.defineMetadata(ValidationDecorators._maxlenghtKeyMetadata, { Message: msg, Max: max }, target, property);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static GetMaxlenght(target, property) {
|
|
49
|
+
return ValidationDecorators.TryGetValue(target, property, ValidationDecorators._maxlenghtKeyMetadata);
|
|
50
|
+
}
|
|
51
|
+
static MinLenght(min, message) {
|
|
52
|
+
return function (target, property) {
|
|
53
|
+
ValidationDecorators.AddField(target, property);
|
|
54
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} must be a minimum of ${min} caracteres`;
|
|
55
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._minlenghtKeyMetadata, property, { Message: msg, Min: min });
|
|
56
|
+
Reflect.defineMetadata(ValidationDecorators._minlenghtKeyMetadata, { Message: msg, Min: min }, target, property);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
static GetMinlenght(target, property) {
|
|
60
|
+
return ValidationDecorators.TryGetValue(target, property, ValidationDecorators._minlenghtKeyMetadata);
|
|
61
|
+
}
|
|
62
|
+
static MinValue(min, message) {
|
|
63
|
+
return function (target, property) {
|
|
64
|
+
ValidationDecorators.AddField(target, property);
|
|
65
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} must be a minimum value of ${min}`;
|
|
66
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._minValueKeyMetadata, property, { Message: msg, Min: min });
|
|
67
|
+
Reflect.defineMetadata(ValidationDecorators._minValueKeyMetadata, { Message: msg, Min: min }, target, property);
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
static GetMinValue(target, property) {
|
|
71
|
+
return ValidationDecorators.TryGetValue(target, property, ValidationDecorators._minValueKeyMetadata);
|
|
72
|
+
}
|
|
73
|
+
static MaxValue(max, message) {
|
|
74
|
+
return function (target, property) {
|
|
75
|
+
ValidationDecorators.AddField(target, property);
|
|
76
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} must be a maximun value of ${max}`;
|
|
77
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._maxValueKeyMetadata, property, { Message: msg, Max: max });
|
|
78
|
+
Reflect.defineMetadata(ValidationDecorators._maxValueKeyMetadata, { Message: msg, Max: max }, target, property);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
static GetMaxValue(target, property) {
|
|
82
|
+
return ValidationDecorators.TryGetValue(target, property, ValidationDecorators._maxValueKeyMetadata);
|
|
83
|
+
}
|
|
84
|
+
static Regex(regex, message) {
|
|
85
|
+
return function (target, property) {
|
|
86
|
+
ValidationDecorators.AddField(target, property);
|
|
87
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} fails on validation expression`;
|
|
88
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._regexKeyMetadata, property, { Message: msg, RegExp: regex });
|
|
89
|
+
Reflect.defineMetadata(ValidationDecorators._regexKeyMetadata, { Message: msg, RegExp: regex }, target, property);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
static GetRegex(target, property) {
|
|
93
|
+
return Reflect.getMetadata(ValidationDecorators._regexKeyMetadata, target, property);
|
|
94
|
+
}
|
|
95
|
+
static Rule(validationFunction, message) {
|
|
96
|
+
return function (target, property) {
|
|
97
|
+
ValidationDecorators.AddField(target, property);
|
|
98
|
+
let msg = message !== null && message !== void 0 ? message : `The field ${target.constructor.name}.${property} fails on validation expression`;
|
|
99
|
+
OwnMetaDataContainer_1.default.Set(target.constructor, ValidationDecorators._ruleKeyMetadata, property, { Message: msg, Function: validationFunction });
|
|
100
|
+
Reflect.defineMetadata(ValidationDecorators._ruleKeyMetadata, { Message: msg, Function: validationFunction }, target, property);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static GetRule(target, property) {
|
|
104
|
+
return Reflect.getMetadata(ValidationDecorators._ruleKeyMetadata, target, property);
|
|
105
|
+
}
|
|
106
|
+
static Validate(object) {
|
|
107
|
+
let result = [];
|
|
108
|
+
let o = object;
|
|
109
|
+
let cache = [];
|
|
110
|
+
for (let k of ValidationDecorators.GetFields(o)) {
|
|
111
|
+
let required = ValidationDecorators.IsRequired(o, k);
|
|
112
|
+
let maxLenght = ValidationDecorators.GetMaxlenght(o, k);
|
|
113
|
+
let minLenght = ValidationDecorators.GetMinlenght(o, k);
|
|
114
|
+
let maxValue = ValidationDecorators.GetMaxValue(o, k);
|
|
115
|
+
let minValue = ValidationDecorators.GetMinValue(o, k);
|
|
116
|
+
let regex = ValidationDecorators.GetRegex(o, k);
|
|
117
|
+
let action = ValidationDecorators.GetRule(o, k);
|
|
118
|
+
if (required && cache.filter(c => c.f == k && c.k == "r").length == 0) {
|
|
119
|
+
cache.push({ f: k, k: "r" });
|
|
120
|
+
if (!o[k])
|
|
121
|
+
result.push(required.Message);
|
|
122
|
+
}
|
|
123
|
+
if (maxLenght && cache.filter(c => c.f == k && c.k == "ml").length == 0) {
|
|
124
|
+
cache.push({ f: k, k: "ml" });
|
|
125
|
+
if (o[k] && (typeof o[k] == "string" && o[k].length > maxLenght.Max))
|
|
126
|
+
result.push(maxLenght.Message);
|
|
127
|
+
}
|
|
128
|
+
if (minLenght && cache.filter(c => c.f == k && c.k == "nl").length == 0) {
|
|
129
|
+
cache.push({ f: k, k: "nl" });
|
|
130
|
+
if (!o[k] || (typeof o[k] == "string" && o[k].length < minLenght.Min))
|
|
131
|
+
result.push(minLenght.Message);
|
|
132
|
+
}
|
|
133
|
+
if (regex && cache.filter(c => c.f == k && c.k == "rg").length == 0) {
|
|
134
|
+
cache.push({ f: k, k: "rg" });
|
|
135
|
+
if (!o[k] || (typeof o[k] == "string" && !regex.RegExp.test(o[k])))
|
|
136
|
+
result.push(regex.Message);
|
|
137
|
+
}
|
|
138
|
+
if (minValue && cache.filter(c => c.f == k && c.k == "mv").length == 0) {
|
|
139
|
+
cache.push({ f: k, k: "mv" });
|
|
140
|
+
if (!o[k] || (typeof o[k] == "number" && o[k] < minValue.Min))
|
|
141
|
+
result.push(minValue.Message);
|
|
142
|
+
}
|
|
143
|
+
if (maxValue && cache.filter(c => c.f == k && c.k == "nv").length == 0) {
|
|
144
|
+
cache.push({ f: k, k: "nv" });
|
|
145
|
+
if (!o[k] || (typeof o[k] == "number" && o[k] > maxValue.Max))
|
|
146
|
+
result.push(maxValue.Message);
|
|
147
|
+
}
|
|
148
|
+
if (action && cache.filter(c => c.f == k && c.k == "a").length == 0) {
|
|
149
|
+
cache.push({ f: k, k: "a" });
|
|
150
|
+
let actionResult = false;
|
|
151
|
+
try {
|
|
152
|
+
actionResult = action.Function(o[k]);
|
|
153
|
+
}
|
|
154
|
+
catch (_a) { }
|
|
155
|
+
if (!actionResult)
|
|
156
|
+
result.push(action.Message);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
static TryGetValue(target, property, key) {
|
|
162
|
+
var _a;
|
|
163
|
+
let meta = (_a = Reflect.getMetadata(key, target, property)) !== null && _a !== void 0 ? _a : Reflect.getMetadata(key, target.constructor, property);
|
|
164
|
+
if (!meta) {
|
|
165
|
+
let ownMeta = OwnMetaDataContainer_1.default.Get(target, key, property);
|
|
166
|
+
if (ownMeta)
|
|
167
|
+
meta = ownMeta.Value;
|
|
168
|
+
}
|
|
169
|
+
return meta;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.default = ValidationDecorators;
|
|
173
|
+
ValidationDecorators._requiredKeyMetadata = "meta:validation-required";
|
|
174
|
+
ValidationDecorators._maxlenghtKeyMetadata = "meta:validation-maxLenght";
|
|
175
|
+
ValidationDecorators._minlenghtKeyMetadata = "meta:validation-minLenght";
|
|
176
|
+
ValidationDecorators._regexKeyMetadata = "meta:validation-regex";
|
|
177
|
+
ValidationDecorators._ruleKeyMetadata = "meta:validation-rule";
|
|
178
|
+
ValidationDecorators._maxValueKeyMetadata = "meta:validation-maxValue";
|
|
179
|
+
ValidationDecorators._minValueKeyMetadata = "meta:validation-minValue";
|
|
180
|
+
ValidationDecorators._keysToValidateKeyMetada = "meta:mustValidate";
|
|
181
|
+
//# sourceMappingURL=ValidationDecorators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationDecorators.js","sourceRoot":"","sources":["../../../decorators/validations/ValidationDecorators.ts"],"names":[],"mappings":";;;;;AAAA,4BAA0B;AAC1B,+FAAqE;AAGrE,MAAqB,oBAAoB;IAErC;IAGA,CAAC;IAYM,MAAM,CAAC,QAAQ,CAAC,MAAe,EAAE,QAAiB;QAErD,IAAI,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpB,OAAO,CAAC,cAAc,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAChG,8BAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,wBAAwB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/G,CAAC;IAEM,MAAM,CAAC,SAAS,CAAC,MAAe;;QAEnC,IAAI,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,MAAM,CAAC,mCACrF,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,wBAAwB,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAEvF,IAAG,CAAC,IAAI,EACR;YACI,IAAI,OAAO,GAAG,8BAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;YAE5F,IAAG,OAAO;gBACN,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;;gBAErB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WAAW,CAAI,MAAe,EAAE,QAAiB,EAAE,GAAY;;QAE1E,IAAI,IAAI,GAAG,MAAA,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,mCAC1C,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAClE,IAAG,CAAC,IAAI,EACR;YACI,IAAI,OAAO,GAAG,8BAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;YAE5D,IAAG,OAAO;gBACN,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC;SAC5B;QAED,OAAO,IAAS,CAAC;IACrB,CAAC;;AAxPL,uCA0PC;AAnPkB,yCAAoB,GAAG,0BAA0B,CAAC;AAClD,0CAAqB,GAAG,2BAA2B,CAAC;AACpD,0CAAqB,GAAG,2BAA2B,CAAC;AACpD,sCAAiB,GAAG,uBAAuB,CAAC;AAC5C,qCAAgB,GAAG,sBAAsB,CAAC;AAC1C,yCAAoB,GAAG,0BAA0B,CAAC;AAClD,yCAAoB,GAAG,0BAA0B,CAAC;AAClD,6CAAwB,GAAG,mBAAmB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,13 @@ export declare function DELETE(action?: string): (target: Object, methodName: st
|
|
|
21
21
|
export declare function Verb(verb: HTTPVerbs): (target: Object, methodName: string, propertyDescriptor: PropertyDescriptor) => void;
|
|
22
22
|
export declare function Inject(): (target: Object, property: string | symbol) => void;
|
|
23
23
|
export declare function InjectAbstract(cTor: Function): (target: Object, property: string | symbol) => void;
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
24
|
+
export declare function Validate(): (target: Function) => void;
|
|
25
|
+
export declare function Required(message?: string): (target: Object, property: string) => void;
|
|
26
|
+
export declare function MaxLenght(max: number, message?: string): (target: Object, property: string) => void;
|
|
27
|
+
export declare function MinLenght(min: number, message?: string): (target: Object, property: string) => void;
|
|
28
|
+
export declare function Max(max: number, message?: string): (target: Object, property: string) => void;
|
|
29
|
+
export declare function Min(min: number, message?: string): (target: Object, property: string) => void;
|
|
30
|
+
export declare function Regex(regex: RegExp, message?: string): (target: Object, property: string) => void;
|
|
31
|
+
export declare function Rule<T>(action: (a: T) => boolean, message?: string): (target: Object, property: string) => void;
|
|
32
|
+
export declare function FromBody(paramName?: string): (target: Object, methodName: string, parameterIndex: number) => void;
|
|
33
|
+
export declare function FromQuery(paramName?: string): (target: Object, methodName: string, parameterIndex: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.FromQuery = exports.FromBody = exports.Rule = exports.Regex = exports.Min = exports.Max = exports.MinLenght = exports.MaxLenght = exports.Required = exports.Validate = exports.InjectAbstract = exports.Inject = exports.Verb = exports.DELETE = exports.PUT = exports.POST = exports.GET = exports.Route = exports.Action = exports.Run = exports.Use = exports.DependecyService = exports.HTTPVerbs = exports.ControllerBase = exports.ControllersDecorators = exports.ApplicationConfiguration = exports.Application = void 0;
|
|
7
7
|
var Application_1 = require("./Application");
|
|
8
8
|
Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return __importDefault(Application_1).default; } });
|
|
9
9
|
var ApplicationConfiguration_1 = require("./ApplicationConfiguration");
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "HTTPVerbs", { enumerable: true, get: function ()
|
|
|
17
17
|
var DependecyService_1 = require("./dependencyInjection/DependecyService");
|
|
18
18
|
Object.defineProperty(exports, "DependecyService", { enumerable: true, get: function () { return __importDefault(DependecyService_1).default; } });
|
|
19
19
|
const ControllerDecorators_2 = __importDefault(require("./decorators/controllers/ControllerDecorators"));
|
|
20
|
+
const ValidationDecorators_1 = __importDefault(require("./decorators/validations/ValidationDecorators"));
|
|
20
21
|
const DependecyService_2 = __importDefault(require("./dependencyInjection/DependecyService"));
|
|
21
22
|
const HttpVerbs_2 = require("./enums/httpVerbs/HttpVerbs");
|
|
22
23
|
function Use(midleware) {
|
|
@@ -72,8 +73,44 @@ function InjectAbstract(cTor) {
|
|
|
72
73
|
return DependecyService_2.default.InjectOne(cTor);
|
|
73
74
|
}
|
|
74
75
|
exports.InjectAbstract = InjectAbstract;
|
|
75
|
-
function
|
|
76
|
-
return ControllerDecorators_2.default.
|
|
76
|
+
function Validate() {
|
|
77
|
+
return ControllerDecorators_2.default.Validate();
|
|
77
78
|
}
|
|
78
|
-
exports.
|
|
79
|
+
exports.Validate = Validate;
|
|
80
|
+
function Required(message) {
|
|
81
|
+
return ValidationDecorators_1.default.Required(message);
|
|
82
|
+
}
|
|
83
|
+
exports.Required = Required;
|
|
84
|
+
function MaxLenght(max, message) {
|
|
85
|
+
return ValidationDecorators_1.default.MaxLenght(max, message);
|
|
86
|
+
}
|
|
87
|
+
exports.MaxLenght = MaxLenght;
|
|
88
|
+
function MinLenght(min, message) {
|
|
89
|
+
return ValidationDecorators_1.default.MinLenght(min, message);
|
|
90
|
+
}
|
|
91
|
+
exports.MinLenght = MinLenght;
|
|
92
|
+
function Max(max, message) {
|
|
93
|
+
return ValidationDecorators_1.default.MaxValue(max, message);
|
|
94
|
+
}
|
|
95
|
+
exports.Max = Max;
|
|
96
|
+
function Min(min, message) {
|
|
97
|
+
return ValidationDecorators_1.default.MinValue(min, message);
|
|
98
|
+
}
|
|
99
|
+
exports.Min = Min;
|
|
100
|
+
function Regex(regex, message) {
|
|
101
|
+
return ValidationDecorators_1.default.Regex(regex, message);
|
|
102
|
+
}
|
|
103
|
+
exports.Regex = Regex;
|
|
104
|
+
function Rule(action, message) {
|
|
105
|
+
return ValidationDecorators_1.default.Rule(action, message);
|
|
106
|
+
}
|
|
107
|
+
exports.Rule = Rule;
|
|
108
|
+
function FromBody(paramName) {
|
|
109
|
+
return ControllerDecorators_2.default.FromBody(paramName);
|
|
110
|
+
}
|
|
111
|
+
exports.FromBody = FromBody;
|
|
112
|
+
function FromQuery(paramName) {
|
|
113
|
+
return ControllerDecorators_2.default.FromQuery(paramName);
|
|
114
|
+
}
|
|
115
|
+
exports.FromQuery = FromQuery;
|
|
79
116
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;AAAA,6CAAsD;AAA7C,2HAAA,OAAO,OAAe;AAC/B,uEAAiF;AAAxE,qJAAA,OAAO,OAA4B;AAE5C,sFAAiG;AAAxF,8IAAA,OAAO,OAAyB;AACzC,oEAAmE;AAA1D,gHAAA,cAAc,OAAA;AAEvB,yDAAwD;AAA/C,sGAAA,SAAS,OAAA;AAElB,2EAAqF;AAA5E,qIAAA,OAAO,OAAoB;AAQpC,yGAAkF;AAClF,8FAAsE;AACtE,2DAAwD;AAGxD,SAAgB,GAAG,CAAC,SAAsB;IAEtC,OAAO,8BAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC;AAHD,kBAGC;AAAC,CAAC;AAEH,SAAgB,GAAG,CAAC,SAAsB;IAEtC,OAAO,8BAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AACnD,CAAC;AAHD,kBAGC;AAAC,CAAC;AAEH,SAAgB,MAAM,CAAC,UAAoB;IAEvC,OAAO,8BAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC;AAHD,wBAGC;AAAC,CAAC;AAEH,SAAgB,KAAK,CAAC,KAAe;IAEjC,OAAO,8BAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9C,CAAC;AAHD,sBAGC;AAAC,CAAC;AAEH,SAAgB,GAAG,CAAC,MAAgB;IAEhC,OAA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EhE,OAAO,8BAAoB,CAAC,IAAI,CAAI,MAAM,EAAE,OAAO,CAAC,CAAC;AACzD,CAAC;AAHD,oBAGC;AAED,SAAgB,QAAQ,CAAC,SAAmB;IAExC,OAAO,8BAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACrD,CAAC;AAHD,4BAGC;AAED,SAAgB,SAAS,CAAC,SAAmB;IAEzC,OAAO,8BAAqB,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;AACtD,CAAC;AAHD,8BAGC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class OwnMetaDataContainer {
|
|
2
|
+
private static _metadas;
|
|
3
|
+
static Get(target: any, key: string, member?: string): IMetaData | undefined;
|
|
4
|
+
static Set(target: Function, key: string, member?: string, value?: any): void;
|
|
5
|
+
private static TryFindCtor;
|
|
6
|
+
}
|
|
7
|
+
export interface IMetaData {
|
|
8
|
+
CTor: Function;
|
|
9
|
+
Member?: string;
|
|
10
|
+
Key: string;
|
|
11
|
+
Value?: any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class OwnMetaDataContainer {
|
|
4
|
+
static Get(target, key, member) {
|
|
5
|
+
let meta = this._metadas.filter(s => s.Key == key && OwnMetaDataContainer.TryFindCtor(s.CTor, target) && (s.Member == member || (s.Member == undefined && member == undefined)));
|
|
6
|
+
if (meta && meta.length > 0)
|
|
7
|
+
return meta[0];
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
static Set(target, key, member, value) {
|
|
11
|
+
let meta = this.Get(target, key, member);
|
|
12
|
+
if (meta) {
|
|
13
|
+
meta.Value = value;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
this._metadas.push({
|
|
17
|
+
CTor: target,
|
|
18
|
+
Key: key,
|
|
19
|
+
Member: member,
|
|
20
|
+
Value: value
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
static TryFindCtor(cTor, target) {
|
|
25
|
+
let sameType = cTor == target || cTor == target.constructor;
|
|
26
|
+
let sameProto = (target.prototype && target.prototype.constructor == cTor);
|
|
27
|
+
let sameAssign = (target.prototype && target.prototype.constructor.toString() == cTor.toString());
|
|
28
|
+
return sameType || sameProto || sameAssign;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.default = OwnMetaDataContainer;
|
|
32
|
+
OwnMetaDataContainer._metadas = [];
|
|
33
|
+
//# sourceMappingURL=OwnMetaDataContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OwnMetaDataContainer.js","sourceRoot":"","sources":["../../metadata/OwnMetaDataContainer.ts"],"names":[],"mappings":";;AAAA,MAAqB,oBAAoB;IAI9B,MAAM,CAAC,GAAG,CAAC,MAAY,EAAE,GAAY,EAAE,MAAgB;QAE1D,IAAI,IAAI,GAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,SAAS,IAAI,MAAM,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;QAElL,IAAG,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YACtB,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;QAEnB,OAAO,SAAS,CAAC;IACrB,CAAC;IAEM,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,GAAY,EAAE,MAAgB,EAAE,KAAY;QAE7E,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAG,IAAI,EACP;YACI,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACtB;aAED;YACI,IAAI,CAAC,QAAQ,CAAC,IAAI,CACd;gBACI,IAAI,EAAG,MAAM;gBACb,GAAG,EAAG,GAAG;gBACT,MAAM,EAAG,MAAM;gBACf,KAAK,EAAG,KAAK;aAChB,CAAC,CAAC;SACV;IACL,CAAC;IAEO,MAAM,CAAC,WAAW,CAAC,IAAe,EAAE,MAAY;QAEpD,IAAI,QAAQ,GAAG,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,CAAC,WAAW,CAAC;QAC5D,IAAI,SAAS,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC;QAC3E,IAAI,UAAU,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAElG,OAAO,QAAQ,IAAI,SAAS,IAAI,UAAU,CAAC;IAC/C,CAAC;;AAzCL,uCA0CC;AAxCmB,6BAAQ,GAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const index_1 = require("../index");
|
|
13
|
+
const SampleService_1 = require("./service/SampleService");
|
|
14
|
+
class App extends index_1.Application {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
}
|
|
18
|
+
ConfigureAsync(appConfig) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
this.UseCors();
|
|
21
|
+
appConfig.AddScoped(SampleService_1.SampleServiceAbstract, SampleService_1.AnotherService);
|
|
22
|
+
this.UseControllers();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.default = App;
|
|
27
|
+
//# sourceMappingURL=Application.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Application.js","sourceRoot":"","sources":["../../temp/Application.ts"],"names":[],"mappings":";;;;;;;;;;;AAEA,oCAAqF;AAErF,2DAAgF;AAGhF,MAAqB,GAAI,SAAQ,mBAAW;IAExC;QAEI,KAAK,EAAE,CAAC;IACZ,CAAC;IAEqB,cAAc,CAAC,SAAoC;;YAGrE,IAAI,CAAC,OAAO,EAAE,CAAC;YAEf,SAAS,CAAC,SAAS,CAAC,qCAAqB,EAAE,8BAAc,CAAC,CAAC;YAE3D,IAAI,CAAC,cAAc,EAAE,CAAC;QAE1B,CAAC;KAAA;CAGJ;AAnBD,sBAmBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Application_1 = __importDefault(require("./Application"));
|
|
7
|
+
new Application_1.default().StartAsync();
|
|
8
|
+
//# sourceMappingURL=Index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.js","sourceRoot":"","sources":["../../temp/Index.ts"],"names":[],"mappings":";;;;;AAAA,gEAAwC;AAExC,IAAI,qBAAW,EAAE,CAAC,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ControllerBase } from "../../index";
|
|
2
|
+
import { SampleServiceAbstract } from "../service/SampleService";
|
|
3
|
+
export default class StatusController extends ControllerBase {
|
|
4
|
+
SomeService: SampleServiceAbstract;
|
|
5
|
+
TypeInferedInjection?: SampleServiceAbstract;
|
|
6
|
+
constructor(some: SampleServiceAbstract);
|
|
7
|
+
CheckStatus(s: string, some: SampleServiceAbstract): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const index_1 = require("../../index");
|
|
16
|
+
const SampleService_1 = require("../service/SampleService");
|
|
17
|
+
let StatusController = class StatusController extends index_1.ControllerBase {
|
|
18
|
+
constructor(some) {
|
|
19
|
+
super();
|
|
20
|
+
this.SomeService = some;
|
|
21
|
+
this.TypeInferedInjection = undefined;
|
|
22
|
+
}
|
|
23
|
+
CheckStatus(s, some) {
|
|
24
|
+
this.SomeService.DoSomething();
|
|
25
|
+
this.OK({ status: "OK" });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, index_1.InjectAbstract)(SampleService_1.SampleServiceAbstract),
|
|
30
|
+
__metadata("design:type", SampleService_1.SampleServiceAbstract)
|
|
31
|
+
], StatusController.prototype, "SomeService", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, index_1.Inject)(),
|
|
34
|
+
__metadata("design:type", SampleService_1.SampleServiceAbstract)
|
|
35
|
+
], StatusController.prototype, "TypeInferedInjection", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, index_1.Verb)(index_1.HTTPVerbs.GET),
|
|
38
|
+
(0, index_1.Action)("/check"),
|
|
39
|
+
__param(0, (0, index_1.FromBody)()),
|
|
40
|
+
__param(1, (0, index_1.FromBody)()),
|
|
41
|
+
__metadata("design:type", Function),
|
|
42
|
+
__metadata("design:paramtypes", [String, SampleService_1.SampleServiceAbstract]),
|
|
43
|
+
__metadata("design:returntype", void 0)
|
|
44
|
+
], StatusController.prototype, "CheckStatus", null);
|
|
45
|
+
StatusController = __decorate([
|
|
46
|
+
(0, index_1.Route)("/status"),
|
|
47
|
+
(0, index_1.Use)(context => {
|
|
48
|
+
console.log("First midleware");
|
|
49
|
+
context.Next(context);
|
|
50
|
+
}),
|
|
51
|
+
(0, index_1.Use)(context => {
|
|
52
|
+
console.log("Second midleware");
|
|
53
|
+
context.Next(context);
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:paramtypes", [SampleService_1.SampleServiceAbstract])
|
|
56
|
+
], StatusController);
|
|
57
|
+
exports.default = StatusController;
|
|
58
|
+
//# sourceMappingURL=StatusController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StatusController.js","sourceRoot":"","sources":["../../../temp/controllers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
|
|
1
|
+
export declare abstract class SampleServiceAbstract {
|
|
2
|
+
abstract DoSomething(): void;
|
|
3
|
+
}
|
|
4
|
+
export declare class SampleService extends SampleServiceAbstract {
|
|
5
|
+
DoSomething(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class AnotherService extends SampleServiceAbstract {
|
|
8
|
+
DoSomething(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnotherService = exports.SampleService = exports.SampleServiceAbstract = void 0;
|
|
4
|
+
class SampleServiceAbstract {
|
|
5
|
+
}
|
|
6
|
+
exports.SampleServiceAbstract = SampleServiceAbstract;
|
|
7
|
+
class SampleService extends SampleServiceAbstract {
|
|
8
|
+
DoSomething() {
|
|
9
|
+
console.log("Doing");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.SampleService = SampleService;
|
|
13
|
+
class AnotherService extends SampleServiceAbstract {
|
|
14
|
+
DoSomething() {
|
|
15
|
+
console.log("Doing another job");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.AnotherService = AnotherService;
|
|
19
|
+
//# sourceMappingURL=SampleService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SampleService.js","sourceRoot":"","sources":["../../../temp/service/SampleService.ts"],"names":[],"mappings":";;;AAAA,MAAsB,qBAAqB;CAG1C;AAHD,sDAGC;AAID,MAAa,aAAc,SAAQ,qBAAqB;IAE7C,WAAW;QACd,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CACJ;AALD,sCAKC;AAID,MAAa,cAAe,SAAQ,qBAAqB;IAE9C,WAAW;QACd,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACrC,CAAC;CACJ;AALD,wCAKC"}
|