chyz 2.0.0-rc.8 → 2.0.1-rc.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.
Files changed (153) hide show
  1. package/BaseChyz.d.ts +73 -56
  2. package/BaseChyz.d.ts.map +1 -1
  3. package/BaseChyz.js +569 -404
  4. package/README.md +1 -1
  5. package/base/ActionFilter.d.ts +32 -32
  6. package/base/ActionFilter.d.ts.map +1 -1
  7. package/base/ActionFilter.js +82 -82
  8. package/base/BadRequestHttpException.d.ts +6 -0
  9. package/base/BadRequestHttpException.d.ts.map +1 -0
  10. package/base/BadRequestHttpException.js +17 -0
  11. package/base/BaseError.d.ts +43 -10
  12. package/base/BaseError.d.ts.map +1 -1
  13. package/base/BaseError.js +58 -26
  14. package/base/Behavior.d.ts +3 -3
  15. package/base/Behavior.js +7 -7
  16. package/base/CBaseObject.d.ts +4 -4
  17. package/base/CBaseObject.d.ts.map +1 -1
  18. package/base/CBaseObject.js +16 -16
  19. package/base/CEvents.d.ts +13 -0
  20. package/base/CEvents.d.ts.map +1 -0
  21. package/base/CEvents.js +24 -0
  22. package/base/CRequest.d.ts +1 -1
  23. package/base/CRequest.js +10 -10
  24. package/base/CWebController.d.ts +43 -43
  25. package/base/CWebController.d.ts.map +1 -1
  26. package/base/CWebController.js +81 -74
  27. package/base/Component.d.ts +20 -20
  28. package/base/Component.d.ts.map +1 -1
  29. package/base/Component.js +57 -57
  30. package/base/Configurable.d.ts +2 -2
  31. package/base/Configurable.js +8 -8
  32. package/base/DataErrorDbException.d.ts +5 -5
  33. package/base/DataErrorDbException.d.ts.map +1 -1
  34. package/base/DataErrorDbException.js +17 -17
  35. package/base/DbConnection.d.ts +12 -12
  36. package/base/DbConnection.js +53 -53
  37. package/base/ForbiddenHttpException.d.ts +4 -4
  38. package/base/ForbiddenHttpException.d.ts.map +1 -1
  39. package/base/ForbiddenHttpException.js +16 -16
  40. package/base/InvalidArgumentException.d.ts +5 -5
  41. package/base/InvalidArgumentException.d.ts.map +1 -1
  42. package/base/InvalidArgumentException.js +17 -17
  43. package/base/InvalidConfigException.d.ts +5 -5
  44. package/base/InvalidConfigException.d.ts.map +1 -1
  45. package/base/InvalidConfigException.js +17 -17
  46. package/base/Logs.d.ts +21 -21
  47. package/base/Logs.d.ts.map +1 -1
  48. package/base/Logs.js +57 -57
  49. package/base/Model.d.ts +301 -298
  50. package/base/Model.d.ts.map +1 -1
  51. package/base/Model.js +545 -507
  52. package/base/ModelManager.d.ts +1 -1
  53. package/base/ModelManager.js +19 -19
  54. package/base/NotFoundHttpException.d.ts +5 -5
  55. package/base/NotFoundHttpException.d.ts.map +1 -1
  56. package/base/NotFoundHttpException.js +17 -17
  57. package/base/RestClient.d.ts +6 -6
  58. package/base/RestClient.d.ts.map +1 -1
  59. package/base/RestClient.js +25 -25
  60. package/base/UnauthorizedHttpException.d.ts +5 -5
  61. package/base/UnauthorizedHttpException.d.ts.map +1 -1
  62. package/base/UnauthorizedHttpException.js +17 -17
  63. package/base/ValidationHttpException.d.ts +5 -5
  64. package/base/ValidationHttpException.d.ts.map +1 -1
  65. package/base/ValidationHttpException.js +17 -17
  66. package/base/db/Exception.d.ts +6 -6
  67. package/base/db/Exception.js +15 -15
  68. package/base/index.d.ts +19 -18
  69. package/base/index.d.ts.map +1 -1
  70. package/base/index.js +41 -39
  71. package/decorator/Middleware.d.ts +3 -3
  72. package/decorator/Middleware.js +11 -11
  73. package/decorator/controller.d.ts +2 -2
  74. package/decorator/controller.js +24 -24
  75. package/decorator/delete.d.ts +3 -0
  76. package/decorator/delete.d.ts.map +1 -0
  77. package/decorator/delete.js +36 -0
  78. package/decorator/enums/ControllerDecoratorParams.d.ts +5 -5
  79. package/decorator/enums/ControllerDecoratorParams.js +9 -9
  80. package/decorator/get.d.ts +2 -2
  81. package/decorator/get.js +36 -36
  82. package/decorator/index.d.ts +5 -3
  83. package/decorator/index.d.ts.map +1 -1
  84. package/decorator/index.js +13 -9
  85. package/decorator/post.d.ts +2 -2
  86. package/decorator/post.js +36 -36
  87. package/decorator/put.d.ts +3 -0
  88. package/decorator/put.d.ts.map +1 -0
  89. package/decorator/put.js +36 -0
  90. package/filters/AccessControl.d.ts +12 -12
  91. package/filters/AccessControl.d.ts.map +1 -1
  92. package/filters/AccessControl.js +83 -83
  93. package/filters/AccessRule.d.ts +82 -82
  94. package/filters/AccessRule.d.ts.map +1 -1
  95. package/filters/AccessRule.js +136 -137
  96. package/filters/auth/AuthInterface.d.ts +25 -25
  97. package/filters/auth/AuthInterface.js +2 -2
  98. package/filters/auth/AuthMethod.d.ts +37 -37
  99. package/filters/auth/AuthMethod.d.ts.map +1 -1
  100. package/filters/auth/AuthMethod.js +82 -82
  101. package/filters/auth/HttpBasicAuth.d.ts +23 -22
  102. package/filters/auth/HttpBasicAuth.d.ts.map +1 -1
  103. package/filters/auth/HttpBasicAuth.js +78 -72
  104. package/filters/auth/HttpBearerAuth.d.ts +17 -17
  105. package/filters/auth/HttpBearerAuth.d.ts.map +1 -1
  106. package/filters/auth/HttpBearerAuth.js +33 -32
  107. package/filters/auth/HttpHeaderAuth.d.ts +18 -14
  108. package/filters/auth/HttpHeaderAuth.d.ts.map +1 -1
  109. package/filters/auth/HttpHeaderAuth.js +64 -57
  110. package/filters/auth/JwtHttpBearerAuth.d.ts +20 -20
  111. package/filters/auth/JwtHttpBearerAuth.d.ts.map +1 -1
  112. package/filters/auth/JwtHttpBearerAuth.js +87 -81
  113. package/filters/auth/KeyCloakHttpBearerAuth.d.ts +22 -22
  114. package/filters/auth/KeyCloakHttpBearerAuth.js +116 -116
  115. package/filters/auth/index.d.ts +4 -4
  116. package/filters/auth/index.js +11 -11
  117. package/filters/index.d.ts +2 -2
  118. package/filters/index.js +7 -7
  119. package/index.d.ts +28 -21
  120. package/index.d.ts.map +1 -1
  121. package/index.js +71 -60
  122. package/model/RouteDefinition.d.ts +6 -6
  123. package/model/RouteDefinition.js +8 -8
  124. package/package.json +22 -24
  125. package/rbac/AuthAssignment.d.ts +18 -18
  126. package/rbac/AuthAssignment.js +44 -44
  127. package/rbac/AuthItem.d.ts +26 -26
  128. package/rbac/AuthItem.js +51 -51
  129. package/rbac/AuthItemChild.d.ts +18 -18
  130. package/rbac/AuthItemChild.js +43 -43
  131. package/rbac/AuthManager.d.ts +111 -111
  132. package/rbac/AuthManager.d.ts.map +1 -1
  133. package/rbac/AuthManager.js +356 -355
  134. package/rbac/index.d.ts +5 -0
  135. package/rbac/index.d.ts.map +1 -0
  136. package/rbac/index.js +28 -0
  137. package/requiments/Glob.d.ts +2 -2
  138. package/requiments/Glob.js +10 -10
  139. package/requiments/ReflectUtil.js +24 -24
  140. package/requiments/Utils.d.ts +1 -8
  141. package/requiments/Utils.d.ts.map +1 -1
  142. package/requiments/Utils.js +115 -112
  143. package/validators/BooleanValidator.js +1 -1
  144. package/validators/CompareValidator.js +1 -1
  145. package/validators/DateValidator.js +1 -1
  146. package/validators/EmailValidator.js +1 -1
  147. package/validators/Validator.d.ts +17 -17
  148. package/validators/Validator.js +27 -27
  149. package/web/IdentityInterface.d.ts +55 -54
  150. package/web/IdentityInterface.d.ts.map +1 -1
  151. package/web/IdentityInterface.js +8 -8
  152. package/web/WebUser.d.ts +71 -71
  153. package/web/WebUser.js +165 -165
package/README.md CHANGED
@@ -52,7 +52,7 @@ let config = {
52
52
  }
53
53
 
54
54
  }
55
- Chyz.app(config).Start();
55
+ Chyz.app(config).then((server)=>server.Start());
56
56
  ```
57
57
 
58
58
  ##Controller
@@ -1,33 +1,33 @@
1
- /// <reference types="express" />
2
- import { Request, Response } from "../index";
3
- import { CBaseObject } from "./CBaseObject";
4
- export declare class ActionFilter extends CBaseObject {
5
- only: any;
6
- /**
7
- * @var array list of action IDs that this filter should not apply to.
8
- * @see only
9
- */
10
- except: never[];
11
- init(): void;
12
- /**
13
- *
14
- * @param route
15
- * @param req
16
- * @param res
17
- */
18
- beforeFilter(route: any, req: Request, res: Response): Promise<void>;
19
- /**
20
- * This method is invoked right before an action is to be executed (after all possible filters.)
21
- * You may override this method to do last-minute preparation for the action.
22
- * @param Action $action the action to be executed.
23
- * @return bool whether the action should continue to be executed.
24
- */
25
- beforeAction(route: any, req: Request, res: Response): Promise<boolean>;
26
- /**
27
- *
28
- * @param action
29
- * @protected
30
- */
31
- protected isActive(action: any): boolean;
32
- }
1
+ /// <reference types="express" />
2
+ import { Request, Response } from "../index";
3
+ import { CBaseObject } from "./CBaseObject";
4
+ export declare class ActionFilter extends CBaseObject {
5
+ only: any;
6
+ /**
7
+ * @var array list of action IDs that this filter should not apply to.
8
+ * @see only
9
+ */
10
+ except: never[];
11
+ init(): void;
12
+ /**
13
+ *
14
+ * @param route
15
+ * @param req
16
+ * @param res
17
+ */
18
+ beforeFilter(route: any, req: Request, res: Response): Promise<void>;
19
+ /**
20
+ * This method is invoked right before an action is to be executed (after all possible filters.)
21
+ * You may override this method to do last-minute preparation for the action.
22
+ * @param Action $action the action to be executed.
23
+ * @return bool whether the action should continue to be executed.
24
+ */
25
+ beforeAction(route: any, req: Request, res: Response): Promise<boolean>;
26
+ /**
27
+ *
28
+ * @param action
29
+ * @protected
30
+ */
31
+ protected isActive(action: any): boolean;
32
+ }
33
33
  //# sourceMappingURL=ActionFilter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionFilter.d.ts","sourceRoot":"","sources":["../../src/base/ActionFilter.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAEzC,qBAAa,YAAa,SAAQ,WAAW;IAElC,IAAI,EAAE,GAAG,CAAC;IAEjB;;;OAGG;IACI,MAAM,UAAM;IAGZ,IAAI;IAIX;;;;;OAKG;IACU,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ;IAQjE;;;;;OAKG;IACU,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ;IAIjE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG;CA0BjC"}
1
+ {"version":3,"file":"ActionFilter.d.ts","sourceRoot":"","sources":["../../src/base/ActionFilter.ts"],"names":[],"mappings":";AAMA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,UAAU,CAAC;AAE3C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAA;AAEzC,qBAAa,YAAa,SAAQ,WAAW;IAElC,IAAI,EAAE,GAAG,CAAC;IAEjB;;;OAGG;IACI,MAAM,UAAM;IAGZ,IAAI;IAIX;;;;;OAKG;IACU,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ;IAQjE;;;;;OAKG;IACU,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ;IAIjE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG;CA2BjC"}
@@ -1,82 +1,82 @@
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
- exports.ActionFilter = void 0;
13
- const Utils_1 = require("../requiments/Utils");
14
- const CBaseObject_1 = require("./CBaseObject");
15
- class ActionFilter extends CBaseObject_1.CBaseObject {
16
- constructor() {
17
- super(...arguments);
18
- /**
19
- * @var array list of action IDs that this filter should not apply to.
20
- * @see only
21
- */
22
- this.except = [];
23
- }
24
- init() {
25
- }
26
- /**
27
- *
28
- * @param route
29
- * @param req
30
- * @param res
31
- */
32
- beforeFilter(route, req, res) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- if (!this.isActive(route)) {
35
- return;
36
- }
37
- yield this.beforeAction(route, req, res);
38
- });
39
- }
40
- /**
41
- * This method is invoked right before an action is to be executed (after all possible filters.)
42
- * You may override this method to do last-minute preparation for the action.
43
- * @param Action $action the action to be executed.
44
- * @return bool whether the action should continue to be executed.
45
- */
46
- beforeAction(route, req, res) {
47
- return __awaiter(this, void 0, void 0, function* () {
48
- return true;
49
- });
50
- }
51
- /**
52
- *
53
- * @param action
54
- * @protected
55
- */
56
- isActive(action) {
57
- let id = action.id;
58
- let onlyMatch = false;
59
- let exceptMatch = false;
60
- if (Utils_1.Utils.isEmpty(this.only)) {
61
- onlyMatch = true;
62
- }
63
- else {
64
- onlyMatch = false;
65
- for (const onlyKey of this.only) {
66
- if (Utils_1.Utils.matchWildcard(action.id, onlyKey)) {
67
- onlyMatch = true;
68
- break;
69
- }
70
- }
71
- }
72
- for (const exceptKey in this.except) {
73
- let pattern = this.except[exceptKey];
74
- let match = id.match(pattern);
75
- if (match && match.length > 0) {
76
- exceptMatch = true;
77
- }
78
- }
79
- return !exceptMatch && onlyMatch;
80
- }
81
- }
82
- exports.ActionFilter = ActionFilter;
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
+ exports.ActionFilter = void 0;
13
+ const Utils_1 = require("../requiments/Utils");
14
+ const CBaseObject_1 = require("./CBaseObject");
15
+ class ActionFilter extends CBaseObject_1.CBaseObject {
16
+ constructor() {
17
+ super(...arguments);
18
+ /**
19
+ * @var array list of action IDs that this filter should not apply to.
20
+ * @see only
21
+ */
22
+ this.except = [];
23
+ }
24
+ init() {
25
+ }
26
+ /**
27
+ *
28
+ * @param route
29
+ * @param req
30
+ * @param res
31
+ */
32
+ beforeFilter(route, req, res) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ if (!this.isActive(route)) {
35
+ return;
36
+ }
37
+ yield this.beforeAction(route, req, res);
38
+ });
39
+ }
40
+ /**
41
+ * This method is invoked right before an action is to be executed (after all possible filters.)
42
+ * You may override this method to do last-minute preparation for the action.
43
+ * @param Action $action the action to be executed.
44
+ * @return bool whether the action should continue to be executed.
45
+ */
46
+ beforeAction(route, req, res) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ return true;
49
+ });
50
+ }
51
+ /**
52
+ *
53
+ * @param action
54
+ * @protected
55
+ */
56
+ isActive(action) {
57
+ let id = action.id;
58
+ let onlyMatch = false;
59
+ let exceptMatch = false;
60
+ if (Utils_1.Utils.isEmpty(this.only)) {
61
+ onlyMatch = true;
62
+ }
63
+ else {
64
+ onlyMatch = false;
65
+ for (const onlyKey of this.only) {
66
+ if (Utils_1.Utils.matchWildcard(action.id, onlyKey)) {
67
+ onlyMatch = true;
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ for (const exceptKey in this.except) {
73
+ let pattern = this.except[exceptKey];
74
+ let match = id.match(pattern);
75
+ if (match && match.length > 0) {
76
+ exceptMatch = true;
77
+ }
78
+ }
79
+ return !exceptMatch && onlyMatch;
80
+ }
81
+ }
82
+ exports.ActionFilter = ActionFilter;
@@ -0,0 +1,6 @@
1
+ import { BaseError } from "./BaseError";
2
+ export declare class BadRequestHttpException extends BaseError {
3
+ message: string;
4
+ constructor(message: string);
5
+ }
6
+ //# sourceMappingURL=BadRequestHttpException.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BadRequestHttpException.d.ts","sourceRoot":"","sources":["../../src/base/BadRequestHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,uBAAwB,SAAQ,SAAS;IAC7B,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;CAGvC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
+ * Author: Cihan Ozturk
5
+ * E-mail: cihan@chy.com.tr
6
+ * Github:https://github.com/cihan53/
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BadRequestHttpException = void 0;
10
+ const BaseError_1 = require("./BaseError");
11
+ class BadRequestHttpException extends BaseError_1.BaseError {
12
+ constructor(message) {
13
+ super(message, 400);
14
+ this.message = message;
15
+ }
16
+ }
17
+ exports.BadRequestHttpException = BadRequestHttpException;
@@ -1,11 +1,44 @@
1
- export declare class BaseError extends Error {
2
- private statusCode;
3
- constructor(message: string, statusCode?: number);
4
- toString(): string;
5
- toJSON(): {
6
- code: number | undefined;
7
- name: string;
8
- message: string;
9
- };
10
- }
1
+ /**
2
+ * 10.4 Client Error 4xx ............................................65
3
+ * 10.4.1 400 Bad Request .........................................65
4
+ * 10.4.2 401 Unauthorized ........................................66
5
+ * 10.4.3 402 Payment Required ....................................66
6
+ * 10.4.4 403 Forbidden ...........................................66
7
+ * 10.4.5 404 Not Found ...........................................66
8
+ * 10.4.6 405 Method Not Allowed ..................................66
9
+ * 10.4.7 406 Not Acceptable ......................................67
10
+ * 10.4.8 407 Proxy Authentication Required .......................67
11
+ * 10.4.9 408 Request Timeout .....................................67
12
+ * 10.4.10 409 Conflict ............................................67
13
+ * 10.4.11 410 Gone ................................................68
14
+ * 10.4.12 411 Length Required .....................................68
15
+ * 10.4.13 412 Precondition Failed .................................68
16
+ * 10.4.14 413 Request Entity Too Large ............................69
17
+ * 10.4.15 414 Request-URI Too Long ................................69
18
+ * 10.4.16 415 Unsupported Media Type ..............................69
19
+ * 10.4.17 416 Requested Range Not Satisfiable .....................69
20
+ * 10.4.18 417 Expectation Failed ..................................70
21
+ */
22
+ export declare class BaseError extends Error {
23
+ statusCode: number;
24
+ orginal: any;
25
+ private readonly success;
26
+ constructor(message: any, statusCode?: number);
27
+ toString(): string;
28
+ toJSON(): {
29
+ success: boolean;
30
+ code: number;
31
+ name: string;
32
+ message: string;
33
+ stack: string | undefined;
34
+ orginal: any;
35
+ } | {
36
+ success: boolean;
37
+ code: number;
38
+ name: string;
39
+ message: string;
40
+ stack?: undefined;
41
+ orginal?: undefined;
42
+ };
43
+ }
11
44
  //# sourceMappingURL=BaseError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/base/BaseError.ts"],"names":[],"mappings":"AASA,qBAAa,SAAU,SAAQ,KAAK;IAChC,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,MAAM,EAAC,UAAU,SAAI;IAQ1C,QAAQ;IAGR,MAAM;;;;;CAGT"}
1
+ {"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/base/BaseError.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,GAAG,CAAC;IACb,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,OAAO,EAAE,GAAG,EAAE,UAAU,SAAM;IAW1C,QAAQ;IAIR,MAAM;;;;;;;;;;;;;;;CAcT"}
package/base/BaseError.js CHANGED
@@ -1,26 +1,58 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BaseError = void 0;
10
- const Utils_1 = require("../requiments/Utils");
11
- class BaseError extends Error {
12
- constructor(message, statusCode = 500) {
13
- super(message);
14
- this.message = Utils_1.Utils.isString(message) ? message : JSON.stringify(message);
15
- this.name = this.constructor.name; // good practice
16
- this.statusCode = statusCode; // error code for responding to client
17
- //Error.captureStackTrace(this)
18
- }
19
- toString() {
20
- return `${this.name}[${this.statusCode}] ${this.message}`;
21
- }
22
- toJSON() {
23
- return { code: this === null || this === void 0 ? void 0 : this.statusCode, name: this.name, message: this.message };
24
- }
25
- }
26
- exports.BaseError = BaseError;
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
+ * Author: Cihan Ozturk
5
+ * E-mail: cihan@chy.com.tr
6
+ * Github:https://github.com/cihan53/
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.BaseError = void 0;
10
+ const Utils_1 = require("../requiments/Utils");
11
+ /**
12
+ * 10.4 Client Error 4xx ............................................65
13
+ * 10.4.1 400 Bad Request .........................................65
14
+ * 10.4.2 401 Unauthorized ........................................66
15
+ * 10.4.3 402 Payment Required ....................................66
16
+ * 10.4.4 403 Forbidden ...........................................66
17
+ * 10.4.5 404 Not Found ...........................................66
18
+ * 10.4.6 405 Method Not Allowed ..................................66
19
+ * 10.4.7 406 Not Acceptable ......................................67
20
+ * 10.4.8 407 Proxy Authentication Required .......................67
21
+ * 10.4.9 408 Request Timeout .....................................67
22
+ * 10.4.10 409 Conflict ............................................67
23
+ * 10.4.11 410 Gone ................................................68
24
+ * 10.4.12 411 Length Required .....................................68
25
+ * 10.4.13 412 Precondition Failed .................................68
26
+ * 10.4.14 413 Request Entity Too Large ............................69
27
+ * 10.4.15 414 Request-URI Too Long ................................69
28
+ * 10.4.16 415 Unsupported Media Type ..............................69
29
+ * 10.4.17 416 Requested Range Not Satisfiable .....................69
30
+ * 10.4.18 417 Expectation Failed ..................................70
31
+ */
32
+ class BaseError extends Error {
33
+ constructor(message, statusCode = 500) {
34
+ super(message);
35
+ this.success = false;
36
+ this.message = Utils_1.Utils.isString(message) ? message : JSON.stringify(message);
37
+ this.name = this.constructor.name; // good practice
38
+ this.statusCode = statusCode; // error code for responding to client
39
+ //Error.captureStackTrace(this)
40
+ this.orginal = Utils_1.Utils.isString(message) ? message : message;
41
+ }
42
+ toString() {
43
+ return `${this.name}[${this.statusCode}] ${this.message}`;
44
+ }
45
+ toJSON() {
46
+ if (process.env.NODE_ENV == "development" || process.env.NODE_ENV == "dev") {
47
+ return { success: this.success, code: this === null || this === void 0 ? void 0 : this.statusCode, name: this.name.toString(),
48
+ message: this.message.toString(),
49
+ stack: this.stack,
50
+ orginal: this.orginal };
51
+ }
52
+ else {
53
+ return { success: this.success, code: this === null || this === void 0 ? void 0 : this.statusCode, name: this.name.toString(),
54
+ message: this.message.toString() };
55
+ }
56
+ }
57
+ }
58
+ exports.BaseError = BaseError;
@@ -1,4 +1,4 @@
1
- import { CBaseObject } from "./CBaseObject";
2
- export declare class Behavior extends CBaseObject {
3
- }
1
+ import { CBaseObject } from "./CBaseObject";
2
+ export declare class Behavior extends CBaseObject {
3
+ }
4
4
  //# sourceMappingURL=Behavior.d.ts.map
package/base/Behavior.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Behavior = void 0;
4
- const CBaseObject_1 = require("./CBaseObject");
5
- class Behavior extends CBaseObject_1.CBaseObject {
6
- }
7
- exports.Behavior = Behavior;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Behavior = void 0;
4
+ const CBaseObject_1 = require("./CBaseObject");
5
+ class Behavior extends CBaseObject_1.CBaseObject {
6
+ }
7
+ exports.Behavior = Behavior;
@@ -1,5 +1,5 @@
1
- import { Configurable } from "./Configurable";
2
- export declare class CBaseObject implements Configurable {
3
- init(): void;
4
- }
1
+ import { Configurable } from "./Configurable";
2
+ export declare class CBaseObject implements Configurable {
3
+ init(): void;
4
+ }
5
5
  //# sourceMappingURL=CBaseObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CBaseObject.d.ts","sourceRoot":"","sources":["../../src/base/CBaseObject.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C,qBAAa,WAAY,YAAW,YAAY;IAErC,IAAI;CAGd"}
1
+ {"version":3,"file":"CBaseObject.d.ts","sourceRoot":"","sources":["../../src/base/CBaseObject.ts"],"names":[],"mappings":"AAQA,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAG5C,qBAAa,WAAY,YAAW,YAAY;IAErC,IAAI;CAGd"}
@@ -1,16 +1,16 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CBaseObject = void 0;
10
- const index_1 = require("../index");
11
- class CBaseObject {
12
- init() {
13
- index_1.BaseChyz.debug("BaseObject init.....");
14
- }
15
- }
16
- exports.CBaseObject = CBaseObject;
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
4
+ * Author: Cihan Ozturk
5
+ * E-mail: cihan@chy.com.tr
6
+ * Github:https://github.com/cihan53/
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.CBaseObject = void 0;
10
+ const index_1 = require("../index");
11
+ class CBaseObject {
12
+ init() {
13
+ index_1.BaseChyz.debug("BaseObject init.....");
14
+ }
15
+ }
16
+ exports.CBaseObject = CBaseObject;
@@ -0,0 +1,13 @@
1
+ export declare enum CEvents {
2
+ ON_INIT_BEFORE = "oninitbefore",
3
+ ON_INIT_AFTER = "oninitafter",
4
+ ON_MIDDLEWARE = "onmiddleware",
5
+ ON_BEFORE_START = "onbeforestart",
6
+ ON_AFTER_START = "onafterestart",
7
+ ON_START = "onstart",
8
+ ON_BEFORE_ACTION = "onbeferoaction",
9
+ ON_AFTER_ACTION = "onafteraction",
10
+ ON_DB_CONNECTION = "ondbconnection",
11
+ ON_DB_DISCONNECT = "ondbdisconnect"
12
+ }
13
+ //# sourceMappingURL=CEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CEvents.d.ts","sourceRoot":"","sources":["../../src/base/CEvents.ts"],"names":[],"mappings":"AAQA,oBAAY,OAAO;IACf,cAAc,iBAAe;IAC7B,aAAa,gBAAc;IAC3B,aAAa,iBAAe;IAC5B,eAAe,kBAAkB;IACjC,cAAc,kBAAkB;IAChC,QAAQ,YAAY;IAEpB,gBAAgB,mBAAmB;IACnC,eAAe,kBAAkB;IAEjC,gBAAgB,mBAAiB;IACjC,gBAAgB,mBAAiB;CAGpC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CEvents = void 0;
4
+ /*
5
+ *
6
+ * Copyright (c) 2023.. Chy Bilgisayar Bilisim
7
+ * Author: Cihan Ozturk
8
+ * E-mail: cihan@chy.com.tr
9
+ * Github:https://github.com/cihan53/
10
+ *
11
+ */
12
+ var CEvents;
13
+ (function (CEvents) {
14
+ CEvents["ON_INIT_BEFORE"] = "oninitbefore";
15
+ CEvents["ON_INIT_AFTER"] = "oninitafter";
16
+ CEvents["ON_MIDDLEWARE"] = "onmiddleware";
17
+ CEvents["ON_BEFORE_START"] = "onbeforestart";
18
+ CEvents["ON_AFTER_START"] = "onafterestart";
19
+ CEvents["ON_START"] = "onstart";
20
+ CEvents["ON_BEFORE_ACTION"] = "onbeferoaction";
21
+ CEvents["ON_AFTER_ACTION"] = "onafteraction";
22
+ CEvents["ON_DB_CONNECTION"] = "ondbconnection";
23
+ CEvents["ON_DB_DISCONNECT"] = "ondbdisconnect";
24
+ })(CEvents = exports.CEvents || (exports.CEvents = {}));
@@ -1,2 +1,2 @@
1
- export { Request, Response, NextFunction } from "express";
1
+ export { Request, Response, NextFunction } from "express";
2
2
  //# sourceMappingURL=CRequest.d.ts.map
package/base/CRequest.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";
2
- /*
3
- *
4
- * Copyright (c) 2022.. Chy Bilgisayar Bilisim
5
- * Author: Cihan Ozturk
6
- * E-mail: cihan@chy.com.tr
7
- * Github:https://github.com/cihan53/
8
- *
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ /*
3
+ *
4
+ * Copyright (c) 2022.. Chy Bilgisayar Bilisim
5
+ * Author: Cihan Ozturk
6
+ * E-mail: cihan@chy.com.tr
7
+ * Github:https://github.com/cihan53/
8
+ *
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });