chyz 2.0.1-rc.5 → 2.0.1-rc.7
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/BaseChyz.d.ts.map +1 -1
- package/BaseChyz.js +43 -31
- package/README.md +518 -518
- package/base/ActionFilter.js +2 -2
- package/base/CEvents.js +1 -1
- package/base/Model.js +6 -6
- package/base/RestClient.js +2 -2
- package/decorator/Middleware.js +1 -2
- package/decorator/controller.d.ts.map +1 -1
- package/decorator/delete.d.ts.map +1 -1
- package/decorator/enums/ControllerDecoratorParams.js +1 -1
- package/decorator/get.d.ts.map +1 -1
- package/decorator/post.d.ts.map +1 -1
- package/decorator/put.d.ts.map +1 -1
- package/filters/AccessControl.d.ts.map +1 -1
- package/filters/AccessControl.js +1 -1
- package/filters/auth/AuthMethod.js +1 -1
- package/filters/auth/HttpBasicAuth.js +3 -2
- package/filters/auth/JwtHttpBearerAuth.js +3 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/log/config/log4js.json +55 -55
- package/log/log/config/log4js.json +55 -0
- package/package.json +63 -62
- package/rbac/AuthManager.js +3 -3
- package/validators/Validator.js +1 -1
- package/web/WebUser.js +4 -4
package/BaseChyz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAgB,EAAC,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAIjE;;GAEG;AACH,OAAO,EAAqB,cAAc,EAA0B,IAAI,EAAe,MAAM,QAAQ,CAAC;AAKtG,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAgB,EAAC,YAAY,EAAE,OAAO,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E,cAAc,EAAE,KAAK,EAAE,eAAe;IAgBvH;;OAEG;IACG,cAAc;IA8Eb,UAAU;IA2DV,KAAK;CA2Bf"}
|
package/BaseChyz.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -58,7 +68,7 @@ const compression_1 = __importDefault(require("compression"));
|
|
|
58
68
|
// const fs = require('fs');
|
|
59
69
|
const ip_1 = __importDefault(require("ip"));
|
|
60
70
|
const cors_1 = __importDefault(require("cors"));
|
|
61
|
-
const
|
|
71
|
+
const method_override_1 = __importDefault(require("method-override"));
|
|
62
72
|
const Server = (0, express_1.default)();
|
|
63
73
|
const emitter = require('events').EventEmitter;
|
|
64
74
|
const em = new emitter();
|
|
@@ -80,15 +90,15 @@ Object.defineProperty(Server.request, 'identity', {
|
|
|
80
90
|
enumerable: true,
|
|
81
91
|
writable: true
|
|
82
92
|
});
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
const validate_js_1 = __importDefault(require("validate.js"));
|
|
94
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
95
|
+
const utc_1 = __importDefault(require("dayjs/plugin/utc"));
|
|
96
|
+
const relativeTime_1 = __importDefault(require("dayjs/plugin/relativeTime"));
|
|
97
|
+
dayjs_1.default.extend(utc_1.default);
|
|
98
|
+
dayjs_1.default.extend(relativeTime_1.default);
|
|
99
|
+
dayjs_1.default.extend(isTomorrow_1.default);
|
|
100
|
+
dayjs_1.default.extend(calendar_1.default);
|
|
101
|
+
dayjs_1.default.extend(weekOfYear_1.default);
|
|
92
102
|
/**
|
|
93
103
|
* Use
|
|
94
104
|
* selectedBox: {
|
|
@@ -104,37 +114,37 @@ dayjs.extend(weekOfYear_1.default);
|
|
|
104
114
|
* @param arrayItems
|
|
105
115
|
* @param itemConstraints
|
|
106
116
|
*/
|
|
107
|
-
|
|
117
|
+
validate_js_1.default.validators.array = (arrayItems, itemConstraints) => {
|
|
108
118
|
if (!Utils_1.Utils.isArray(arrayItems))
|
|
109
119
|
return { errors: [{ error: 'in not array' }] };
|
|
110
120
|
const arrayItemErrors = arrayItems.reduce((errors, item, index) => {
|
|
111
|
-
const error =
|
|
121
|
+
const error = (0, validate_js_1.default)(item, itemConstraints);
|
|
112
122
|
if (error)
|
|
113
123
|
errors[index] = { error: error };
|
|
114
124
|
return errors;
|
|
115
125
|
}, {});
|
|
116
126
|
return Utils_1.Utils.isEmpty(arrayItemErrors) ? null : { errors: arrayItemErrors };
|
|
117
127
|
};
|
|
118
|
-
|
|
128
|
+
validate_js_1.default.validators.tokenString = (items, itemConstraints) => {
|
|
119
129
|
let arrayItems = items.split(",");
|
|
120
130
|
const arrayItemErrors = arrayItems.reduce((errors, item, index) => {
|
|
121
|
-
const error =
|
|
131
|
+
const error = (0, validate_js_1.default)(item, itemConstraints);
|
|
122
132
|
if (error)
|
|
123
133
|
errors[index] = { error: error };
|
|
124
134
|
return errors;
|
|
125
135
|
}, {});
|
|
126
136
|
return Utils_1.Utils.isEmpty(arrayItemErrors) ? null : { errors: arrayItemErrors };
|
|
127
137
|
};
|
|
128
|
-
|
|
138
|
+
validate_js_1.default.extend(validate_js_1.default.validators.datetime, {
|
|
129
139
|
// The value is guaranteed not to be null or undefined but otherwise it
|
|
130
140
|
// could be anything.
|
|
131
141
|
parse: function (value, options) {
|
|
132
|
-
return +
|
|
142
|
+
return +(0, dayjs_1.default)().utc(value);
|
|
133
143
|
},
|
|
134
144
|
// Input is a unix timestamp
|
|
135
145
|
format: function (value, options) {
|
|
136
146
|
const format = options.dateOnly ? "YYYY-MM-DD" : "YYYY-MM-DD hh:mm:ss";
|
|
137
|
-
return
|
|
147
|
+
return (0, dayjs_1.default)().utc(value).format(format);
|
|
138
148
|
}
|
|
139
149
|
});
|
|
140
150
|
class BaseChyz {
|
|
@@ -205,9 +215,9 @@ class BaseChyz {
|
|
|
205
215
|
static set validate(value) {
|
|
206
216
|
this._validate = value;
|
|
207
217
|
}
|
|
208
|
-
app(
|
|
209
|
-
|
|
210
|
-
|
|
218
|
+
app() {
|
|
219
|
+
return __awaiter(this, arguments, void 0, function* (config = {}) {
|
|
220
|
+
var _a, _b;
|
|
211
221
|
BaseChyz.EventEmitter.emit(base_1.CEvents.ON_INIT_BEFORE, this, config);
|
|
212
222
|
/**
|
|
213
223
|
* Config set
|
|
@@ -490,7 +500,7 @@ class BaseChyz {
|
|
|
490
500
|
var _a;
|
|
491
501
|
BaseChyz.propvider.use(bodyParser.json({ limit: '1mb' }));
|
|
492
502
|
BaseChyz.propvider.use(bodyParser.urlencoded({ limit: '1mb', extended: true })); // support encoded bodies
|
|
493
|
-
BaseChyz.propvider.use(
|
|
503
|
+
BaseChyz.propvider.use((0, method_override_1.default)());
|
|
494
504
|
BaseChyz.propvider.use((0, cors_1.default)());
|
|
495
505
|
//
|
|
496
506
|
// // CORS
|
|
@@ -512,8 +522,10 @@ class BaseChyz {
|
|
|
512
522
|
return false;
|
|
513
523
|
}
|
|
514
524
|
// use compression filter function
|
|
525
|
+
// @ts-ignore
|
|
515
526
|
return compression_1.default.filter(req, res);
|
|
516
527
|
};
|
|
528
|
+
// @ts-ignore
|
|
517
529
|
BaseChyz.propvider.use((0, compression_1.default)({ filter: shouldCompress }));
|
|
518
530
|
//
|
|
519
531
|
// //static file path
|
|
@@ -552,7 +564,7 @@ class BaseChyz {
|
|
|
552
564
|
}
|
|
553
565
|
else {
|
|
554
566
|
BaseChyz.httpServer = (0, http_1.createServer)(BaseChyz.propvider);
|
|
555
|
-
BaseChyz.
|
|
567
|
+
BaseChyz.httpServer.listen(this._port, () => {
|
|
556
568
|
BaseChyz.info("Express Server Start ");
|
|
557
569
|
BaseChyz.info(`Liten Port ${this._port}`);
|
|
558
570
|
BaseChyz.info(`http://localhost:${this._port}`);
|
|
@@ -564,9 +576,9 @@ class BaseChyz {
|
|
|
564
576
|
}
|
|
565
577
|
}
|
|
566
578
|
BaseChyz.propvider = Server;
|
|
567
|
-
BaseChyz.date =
|
|
579
|
+
BaseChyz.date = dayjs_1.default;
|
|
568
580
|
BaseChyz.logs = new base_1.Logs();
|
|
569
|
-
BaseChyz._validate =
|
|
581
|
+
BaseChyz._validate = validate_js_1.default;
|
|
570
582
|
BaseChyz.controllers = [];
|
|
571
583
|
BaseChyz.components = {};
|
|
572
584
|
BaseChyz.middlewares = {};
|