chyz 2.0.0-rc.24 → 2.0.0-rc.25
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 +29 -23
- package/package.json +1 -1
package/BaseChyz.js
CHANGED
|
@@ -31,10 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
/**
|
|
39
|
+
* https server
|
|
40
|
+
*/
|
|
41
|
+
const express_1 = __importDefault(require("express"));
|
|
42
|
+
const bodyParser = require("body-parser");
|
|
43
|
+
const https_1 = require("https");
|
|
44
|
+
const http_1 = require("http");
|
|
38
45
|
const fs = require("fs");
|
|
39
46
|
/**
|
|
40
47
|
* Freamwork
|
|
@@ -45,25 +52,9 @@ const Logs_1 = require("./base/Logs");
|
|
|
45
52
|
const CEvents_1 = require("./base/CEvents");
|
|
46
53
|
const compression = require('compression');
|
|
47
54
|
// const fs = require('fs');
|
|
48
|
-
/**
|
|
49
|
-
* Use
|
|
50
|
-
* selectedBox: {
|
|
51
|
-
* array: {
|
|
52
|
-
* id: {
|
|
53
|
-
* numericality: {
|
|
54
|
-
* onlyInteger: true,
|
|
55
|
-
* greaterThan: 0
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
* },
|
|
60
|
-
* @param arrayItems
|
|
61
|
-
* @param itemConstraints
|
|
62
|
-
*/
|
|
63
55
|
const ip = require('ip');
|
|
64
|
-
const bodyParser = require('body-parser');
|
|
65
56
|
const methodOverride = require('method-override');
|
|
66
|
-
const Server =
|
|
57
|
+
const Server = (0, express_1.default)();
|
|
67
58
|
const cors = require('cors');
|
|
68
59
|
const emitter = require('events').EventEmitter;
|
|
69
60
|
const em = new emitter();
|
|
@@ -91,6 +82,21 @@ const utc = require('dayjs/plugin/utc');
|
|
|
91
82
|
const relative = require('dayjs/plugin/relativeTime');
|
|
92
83
|
dayjs.extend(utc);
|
|
93
84
|
dayjs.extend(relative);
|
|
85
|
+
/**
|
|
86
|
+
* Use
|
|
87
|
+
* selectedBox: {
|
|
88
|
+
* array: {
|
|
89
|
+
* id: {
|
|
90
|
+
* numericality: {
|
|
91
|
+
* onlyInteger: true,
|
|
92
|
+
* greaterThan: 0
|
|
93
|
+
* }
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
* },
|
|
97
|
+
* @param arrayItems
|
|
98
|
+
* @param itemConstraints
|
|
99
|
+
*/
|
|
94
100
|
validate.validators.array = (arrayItems, itemConstraints) => {
|
|
95
101
|
const arrayItemErrors = arrayItems.reduce((errors, item, index) => {
|
|
96
102
|
const error = validate(item, itemConstraints);
|
|
@@ -409,7 +415,7 @@ class BaseChyz {
|
|
|
409
415
|
// //static file path
|
|
410
416
|
if (this.config.staticFilePath) {
|
|
411
417
|
BaseChyz.info('Static file path', this.config.staticFilePath);
|
|
412
|
-
BaseChyz.propvider.use(
|
|
418
|
+
BaseChyz.propvider.use(express_1.default.static(this.config.staticFilePath));
|
|
413
419
|
}
|
|
414
420
|
//Middlewares
|
|
415
421
|
for (const middleware1 of Object.keys(BaseChyz.middlewares)) {
|
|
@@ -430,7 +436,7 @@ class BaseChyz {
|
|
|
430
436
|
BaseChyz.info("Express Server Starting");
|
|
431
437
|
BaseChyz.EventEmitter.emit(CEvents_1.CEvents.ON_BEFORE_START, this);
|
|
432
438
|
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.ssl) {
|
|
433
|
-
BaseChyz.httpServer =
|
|
439
|
+
BaseChyz.httpServer = (0, https_1.createServer)((_b = this.config) === null || _b === void 0 ? void 0 : _b.ssl, BaseChyz.propvider);
|
|
434
440
|
BaseChyz.httpServer.listen(this._port, () => {
|
|
435
441
|
BaseChyz.info("Express Server Start ");
|
|
436
442
|
BaseChyz.info(`Liten Port ${this._port}`);
|
|
@@ -440,7 +446,7 @@ class BaseChyz {
|
|
|
440
446
|
});
|
|
441
447
|
}
|
|
442
448
|
else {
|
|
443
|
-
BaseChyz.httpServer =
|
|
449
|
+
BaseChyz.httpServer = (0, http_1.createServer)(BaseChyz.propvider);
|
|
444
450
|
BaseChyz.propvider.listen(this._port, () => {
|
|
445
451
|
BaseChyz.info("Express Server Start ");
|
|
446
452
|
BaseChyz.info(`Liten Port ${this._port}`);
|