chyz 2.0.0-rc.31 → 2.0.0-rc.33
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 +22 -4
- package/base/Model.js +1 -1
- package/package.json +1 -1
package/BaseChyz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AA+GjC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IACvB,MAAM,CAAC,SAAS,EAAE,GAAG,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAgB;IAC7B,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,IAAI,EAAE,GAAG,CAAS;IACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACnB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiB;IACzC,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAA4B;IACtD,OAAc,UAAU,EAAE,GAAG,CAAK;IAClC,OAAc,WAAW,EAAE,GAAG,CAAK;IACnC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAU;IAGtC,MAAM,KAAK,YAAY,IAAI,GAAG,CAE7B;IAED,MAAM,KAAK,YAAY,CAAC,KAAK,EAAE,GAAG,EAEjC;IAED,IAAI,cAAc,IAAI,MAAM,CAE3B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
|
@@ -50,6 +50,7 @@ const base_1 = require("./base");
|
|
|
50
50
|
const Utils_1 = __importStar(require("./requiments/Utils"));
|
|
51
51
|
const Logs_1 = require("./base/Logs");
|
|
52
52
|
const CEvents_1 = require("./base/CEvents");
|
|
53
|
+
const http_request_body = require('debug')('http:request:body');
|
|
53
54
|
const compression = require('compression');
|
|
54
55
|
// const fs = require('fs');
|
|
55
56
|
const ip = require('ip');
|
|
@@ -203,7 +204,7 @@ class BaseChyz {
|
|
|
203
204
|
this._validate = value;
|
|
204
205
|
}
|
|
205
206
|
app(config = {}) {
|
|
206
|
-
var _a;
|
|
207
|
+
var _a, _b;
|
|
207
208
|
BaseChyz.EventEmitter.emit(CEvents_1.CEvents.ON_INIT_BEFORE, this, config);
|
|
208
209
|
/**
|
|
209
210
|
* Config set
|
|
@@ -217,12 +218,27 @@ class BaseChyz {
|
|
|
217
218
|
}
|
|
218
219
|
let components = Utils_1.Utils.findKeyValue(config, "components");
|
|
219
220
|
if (components) {
|
|
221
|
+
/**
|
|
222
|
+
* first initial database component
|
|
223
|
+
*/
|
|
224
|
+
if (components.db) {
|
|
225
|
+
let comp = components['db'];
|
|
226
|
+
BaseChyz.debug("First initial database component ", "db");
|
|
227
|
+
try {
|
|
228
|
+
BaseChyz.components["db"] = Utils_1.Utils.createObject(new comp.class, comp);
|
|
229
|
+
(_a = BaseChyz.components["db"]) === null || _a === void 0 ? void 0 : _a.init();
|
|
230
|
+
delete components.db;
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
BaseChyz.error("Create Component Error", e);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
220
236
|
for (const componentsKey in components) {
|
|
221
237
|
let comp = components[componentsKey];
|
|
222
238
|
BaseChyz.debug("Create Component ", componentsKey);
|
|
223
239
|
try {
|
|
224
240
|
BaseChyz.components[componentsKey] = Utils_1.Utils.createObject(new comp.class, comp);
|
|
225
|
-
(
|
|
241
|
+
(_b = BaseChyz.components[componentsKey]) === null || _b === void 0 ? void 0 : _b.init();
|
|
226
242
|
}
|
|
227
243
|
catch (e) {
|
|
228
244
|
BaseChyz.error("Create Component Error", e);
|
|
@@ -349,12 +365,14 @@ class BaseChyz {
|
|
|
349
365
|
BaseChyz.debug("Controller load ", controller.name, `(${prefix})`);
|
|
350
366
|
if (routes) {
|
|
351
367
|
routes.forEach(route => {
|
|
352
|
-
let actionId = route.path == "/" || route.path == "" ? instance.defaultAction : route.path;
|
|
368
|
+
let actionId = (route.path == "/" || route.path == "") ? instance.defaultAction : route.path;
|
|
353
369
|
route.id = actionId;
|
|
354
370
|
BaseChyz.debug("Controller route Path", prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`));
|
|
355
371
|
BaseChyz.propvider[route.requestMethod](prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`), (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
356
372
|
try {
|
|
357
|
-
BaseChyz.debug(`Call Request id ${
|
|
373
|
+
BaseChyz.debug(`Call Request id ${actionId}`);
|
|
374
|
+
http_request_body("Request body");
|
|
375
|
+
http_request_body(req.body);
|
|
358
376
|
yield instance.beforeAction(route, req, res);
|
|
359
377
|
next();
|
|
360
378
|
}
|
package/base/Model.js
CHANGED
|
@@ -113,7 +113,7 @@ class Model extends Component_1.Component {
|
|
|
113
113
|
* @return Connection the database connection used by this AR class.
|
|
114
114
|
*/
|
|
115
115
|
getDb() {
|
|
116
|
-
return BaseChyz_1.default.getComponent("db").db;
|
|
116
|
+
return BaseChyz_1.default.getComponent("db") ? BaseChyz_1.default.getComponent("db").db : null;
|
|
117
117
|
}
|
|
118
118
|
getDbConnection() {
|
|
119
119
|
return BaseChyz_1.default.getComponent("db");
|