chyz 2.0.1-rc.5 → 2.0.1-rc.6
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.js +41 -31
- package/README.md +518 -518
- 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.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/log/config/log4js.json +55 -55
- 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.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
|
|
@@ -552,7 +562,7 @@ class BaseChyz {
|
|
|
552
562
|
}
|
|
553
563
|
else {
|
|
554
564
|
BaseChyz.httpServer = (0, http_1.createServer)(BaseChyz.propvider);
|
|
555
|
-
BaseChyz.
|
|
565
|
+
BaseChyz.httpServer.listen(this._port, () => {
|
|
556
566
|
BaseChyz.info("Express Server Start ");
|
|
557
567
|
BaseChyz.info(`Liten Port ${this._port}`);
|
|
558
568
|
BaseChyz.info(`http://localhost:${this._port}`);
|
|
@@ -564,9 +574,9 @@ class BaseChyz {
|
|
|
564
574
|
}
|
|
565
575
|
}
|
|
566
576
|
BaseChyz.propvider = Server;
|
|
567
|
-
BaseChyz.date =
|
|
577
|
+
BaseChyz.date = dayjs_1.default;
|
|
568
578
|
BaseChyz.logs = new base_1.Logs();
|
|
569
|
-
BaseChyz._validate =
|
|
579
|
+
BaseChyz._validate = validate_js_1.default;
|
|
570
580
|
BaseChyz.controllers = [];
|
|
571
581
|
BaseChyz.components = {};
|
|
572
582
|
BaseChyz.middlewares = {};
|