chyz 1.2.4-rc.1 → 1.2.4-rc.4

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 (180) hide show
  1. package/{dist/BaseChyz.js → BaseChyz.js} +3 -0
  2. package/BaseChyz.js.map +1 -0
  3. package/{dist/Chyz.js → Chyz.js} +0 -0
  4. package/{dist/Chyz.js.map → Chyz.js.map} +0 -0
  5. package/{dist/base → base}/ActionFilter.js +0 -0
  6. package/{dist/base → base}/ActionFilter.js.map +0 -0
  7. package/{dist/base → base}/BaseError.js +0 -0
  8. package/{dist/base → base}/BaseError.js.map +0 -0
  9. package/{dist/base → base}/BaseObject.js +0 -0
  10. package/{dist/base → base}/BaseObject.js.map +0 -0
  11. package/{dist/base → base}/Behavior.js +0 -0
  12. package/{dist/base → base}/Behavior.js.map +0 -0
  13. package/{dist/base → base}/CWebController.js +0 -0
  14. package/{dist/base → base}/CWebController.js.map +0 -0
  15. package/{dist/base → base}/Component.js +0 -0
  16. package/{dist/base → base}/Component.js.map +0 -0
  17. package/{dist/base → base}/Configurable.js +0 -0
  18. package/{dist/base → base}/Configurable.js.map +0 -0
  19. package/{dist/base → base}/DataErrorDbException.js +0 -0
  20. package/{dist/base → base}/DataErrorDbException.js.map +0 -0
  21. package/{dist/base → base}/DbConnection.js +0 -0
  22. package/{dist/base → base}/DbConnection.js.map +0 -0
  23. package/{dist/base → base}/ForbiddenHttpException.js +0 -0
  24. package/{dist/base → base}/ForbiddenHttpException.js.map +0 -0
  25. package/{dist/base → base}/InvalidArgumentException.js +0 -0
  26. package/{dist/base → base}/InvalidArgumentException.js.map +0 -0
  27. package/{dist/base → base}/InvalidConfigException.js +0 -0
  28. package/{dist/base → base}/InvalidConfigException.js.map +0 -0
  29. package/{dist/base → base}/Model.js +0 -0
  30. package/{dist/base → base}/Model.js.map +0 -0
  31. package/{dist/base → base}/ModelManager.js +0 -0
  32. package/{dist/base → base}/ModelManager.js.map +0 -0
  33. package/{dist/base → base}/NotFoundHttpException.js +0 -0
  34. package/{dist/base → base}/NotFoundHttpException.js.map +0 -0
  35. package/{dist/base → base}/RestClient.js +0 -0
  36. package/{dist/base → base}/RestClient.js.map +0 -0
  37. package/{dist/base → base}/UnauthorizedHttpException.js +0 -0
  38. package/{dist/base → base}/UnauthorizedHttpException.js.map +0 -0
  39. package/{dist/base → base}/ValidationHttpException.js +0 -0
  40. package/{dist/base → base}/ValidationHttpException.js.map +0 -0
  41. package/{dist/base → base}/db/Exception.js +0 -0
  42. package/{dist/base → base}/db/Exception.js.map +0 -0
  43. package/{dist/base → base}/index.js +0 -0
  44. package/{dist/base → base}/index.js.map +0 -0
  45. package/{dist/decorator → decorator}/Middleware.js +0 -0
  46. package/{dist/decorator → decorator}/Middleware.js.map +0 -0
  47. package/{dist/decorator → decorator}/controller.js +0 -0
  48. package/{dist/decorator → decorator}/controller.js.map +0 -0
  49. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js +0 -0
  50. package/{dist/decorator → decorator}/enums/ControllerDecoratorParams.js.map +0 -0
  51. package/{dist/decorator → decorator}/get.js +0 -0
  52. package/{dist/decorator → decorator}/get.js.map +0 -0
  53. package/{dist/decorator → decorator}/index.js +0 -0
  54. package/{dist/decorator → decorator}/index.js.map +0 -0
  55. package/{dist/decorator → decorator}/post.js +0 -0
  56. package/{dist/decorator → decorator}/post.js.map +0 -0
  57. package/{dist/filters → filters}/AccessControl.js +0 -0
  58. package/{dist/filters → filters}/AccessControl.js.map +0 -0
  59. package/{dist/filters → filters}/AccessRule.js +0 -0
  60. package/{dist/filters → filters}/AccessRule.js.map +0 -0
  61. package/{dist/filters → filters}/auth/AuthInterface.js +0 -0
  62. package/{dist/filters → filters}/auth/AuthInterface.js.map +0 -0
  63. package/{dist/filters → filters}/auth/AuthMethod.js +0 -0
  64. package/{dist/filters → filters}/auth/AuthMethod.js.map +0 -0
  65. package/{dist/filters → filters}/auth/HttpBasicAuth.js +0 -0
  66. package/{dist/filters → filters}/auth/HttpBasicAuth.js.map +0 -0
  67. package/{dist/filters → filters}/auth/HttpBearerAuth.js +0 -0
  68. package/{dist/filters → filters}/auth/HttpBearerAuth.js.map +0 -0
  69. package/{dist/filters → filters}/auth/HttpHeaderAuth.js +0 -0
  70. package/{dist/filters → filters}/auth/HttpHeaderAuth.js.map +0 -0
  71. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js +0 -0
  72. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js.map +0 -0
  73. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
  74. package/{dist/filters → filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
  75. package/{dist/filters → filters}/auth/index.js +0 -0
  76. package/{dist/filters → filters}/auth/index.js.map +0 -0
  77. package/{dist/filters → filters}/index.js +0 -0
  78. package/{dist/filters → filters}/index.js.map +0 -0
  79. package/{dist/index.js → index.js} +0 -0
  80. package/{dist/index.js.map → index.js.map} +0 -0
  81. package/{dist/model → model}/RouteDefinition.js +0 -0
  82. package/{dist/model → model}/RouteDefinition.js.map +0 -0
  83. package/package.json +3 -2
  84. package/{dist/rbac → rbac}/AuthAssignment.js +0 -0
  85. package/{dist/rbac → rbac}/AuthAssignment.js.map +0 -0
  86. package/{dist/rbac → rbac}/AuthItem.js +0 -0
  87. package/{dist/rbac → rbac}/AuthItem.js.map +0 -0
  88. package/{dist/rbac → rbac}/AuthItemChild.js +0 -0
  89. package/{dist/rbac → rbac}/AuthItemChild.js.map +0 -0
  90. package/{dist/rbac → rbac}/AuthManager.js +0 -0
  91. package/{dist/rbac → rbac}/AuthManager.js.map +0 -0
  92. package/{dist/requiments → requiments}/Glob.js +0 -0
  93. package/{dist/requiments → requiments}/Glob.js.map +0 -0
  94. package/{dist/requiments → requiments}/ReflectUtil.js +0 -0
  95. package/{dist/requiments → requiments}/ReflectUtil.js.map +0 -0
  96. package/{dist/requiments → requiments}/Utils.js +0 -0
  97. package/{dist/requiments → requiments}/Utils.js.map +0 -0
  98. package/{dist/validators → validators}/BooleanValidator.js +0 -0
  99. package/{dist/validators → validators}/BooleanValidator.js.map +0 -0
  100. package/{dist/validators → validators}/CompareValidator.js +0 -0
  101. package/{dist/validators → validators}/CompareValidator.js.map +0 -0
  102. package/{dist/validators → validators}/DateValidator.js +0 -0
  103. package/{dist/validators → validators}/DateValidator.js.map +0 -0
  104. package/{dist/validators → validators}/EmailValidator.js +0 -0
  105. package/{dist/validators → validators}/EmailValidator.js.map +0 -0
  106. package/{dist/validators → validators}/Validator.js +0 -0
  107. package/{dist/validators → validators}/Validator.js.map +0 -0
  108. package/{dist/web → web}/IdentityInterface.js +0 -0
  109. package/{dist/web → web}/IdentityInterface.js.map +0 -0
  110. package/{dist/web → web}/WebUser.js +0 -0
  111. package/{dist/web → web}/WebUser.js.map +0 -0
  112. package/BaseChyz.ts +0 -454
  113. package/Chyz.ts +0 -11
  114. package/Doc/Git.md +0 -29
  115. package/Doc/Moel kullanma.md +0 -13
  116. package/Examples/Controllers/ApiController.ts +0 -110
  117. package/Examples/Models/User.ts +0 -122
  118. package/Examples/index-keycloack.ts +0 -78
  119. package/Examples/index.ts +0 -60
  120. package/Examples/keycloak.json +0 -7
  121. package/Examples/package.json +0 -49
  122. package/Examples/tsconfig.json +0 -21
  123. package/base/ActionFilter.ts +0 -71
  124. package/base/BaseError.ts +0 -28
  125. package/base/BaseObject.ts +0 -19
  126. package/base/Behavior.ts +0 -6
  127. package/base/CWebController.ts +0 -84
  128. package/base/Component.ts +0 -66
  129. package/base/Configurable.ts +0 -10
  130. package/base/DataErrorDbException.ts +0 -16
  131. package/base/DbConnection.ts +0 -55
  132. package/base/ForbiddenHttpException.ts +0 -15
  133. package/base/InvalidArgumentException.ts +0 -16
  134. package/base/InvalidConfigException.ts +0 -16
  135. package/base/Model.ts +0 -555
  136. package/base/ModelManager.ts +0 -19
  137. package/base/NotFoundHttpException.ts +0 -14
  138. package/base/RestClient.ts +0 -28
  139. package/base/UnauthorizedHttpException.ts +0 -17
  140. package/base/ValidationHttpException.ts +0 -14
  141. package/base/db/Exception.ts +0 -14
  142. package/base/index.ts +0 -18
  143. package/decorator/Middleware.ts +0 -9
  144. package/decorator/controller.ts +0 -22
  145. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  146. package/decorator/get.ts +0 -37
  147. package/decorator/index.ts +0 -3
  148. package/decorator/post.ts +0 -36
  149. package/dist/BaseChyz.js.map +0 -1
  150. package/dist/log/config/log4js.json +0 -55
  151. package/dist/package.json +0 -59
  152. package/filters/AccessControl.ts +0 -74
  153. package/filters/AccessRule.ts +0 -182
  154. package/filters/auth/AuthInterface.ts +0 -34
  155. package/filters/auth/AuthMethod.ts +0 -89
  156. package/filters/auth/HttpBasicAuth.ts +0 -75
  157. package/filters/auth/HttpBearerAuth.ts +0 -31
  158. package/filters/auth/HttpHeaderAuth.ts +0 -53
  159. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  160. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  161. package/filters/auth/index.ts +0 -4
  162. package/filters/index.ts +0 -2
  163. package/index.ts +0 -16
  164. package/model/RouteDefinition.ts +0 -18
  165. package/package-lock.json +0 -5259
  166. package/rbac/AuthAssignment.ts +0 -50
  167. package/rbac/AuthItem.ts +0 -57
  168. package/rbac/AuthItemChild.ts +0 -50
  169. package/rbac/AuthManager.ts +0 -398
  170. package/requiments/Glob.ts +0 -9
  171. package/requiments/ReflectUtil.ts +0 -26
  172. package/requiments/Utils.ts +0 -63
  173. package/tsconfig.json +0 -18
  174. package/validators/BooleanValidator.ts +0 -0
  175. package/validators/CompareValidator.ts +0 -0
  176. package/validators/DateValidator.ts +0 -0
  177. package/validators/EmailValidator.ts +0 -0
  178. package/validators/Validator.ts +0 -27
  179. package/web/IdentityInterface.ts +0 -68
  180. package/web/WebUser.ts +0 -187
@@ -1,122 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
- // @ts-ignore
8
-
9
-
10
- import {IdentityInterface} from "../../web/IdentityInterface";
11
- import {DataTypes} from "../../base";
12
- import {BaseChyz} from "../../index";
13
-
14
- const JsonWebToken = require("jsonwebtoken");
15
-
16
- export class User implements IdentityInterface {
17
- [x: string]: any;
18
-
19
-
20
- /**
21
- *
22
- * @param id
23
- */
24
- findIdentity(id: number) {
25
- throw new Error("Method not implemented.");
26
- }
27
-
28
- /**
29
- *
30
- */
31
- getId(): number {
32
- throw new Error("Method not implemented.");
33
- }
34
-
35
- /**
36
- *
37
- * @param permissionName
38
- * @param params
39
- * @param allowCaching
40
- */
41
- can(permissionName: string, params: any[], allowCaching: boolean): boolean | null {
42
- throw new Error("Method not implemented.");
43
- }
44
-
45
- /**
46
- *
47
- */
48
- getAuthKey(): string {
49
- throw new Error("Method not implemented.");
50
- }
51
-
52
- validateAuthKey(authKey: string): boolean {
53
- throw new Error("Method not implemented.");
54
- }
55
-
56
- /**
57
- *
58
- */
59
- public attributes() {
60
- return {
61
- // Model attributes are defined here
62
- name: {
63
- type: DataTypes.STRING,
64
- allowNull: false
65
- },
66
- username: {
67
- type: DataTypes.STRING,
68
- allowNull: false
69
- },
70
- password: {
71
- type: DataTypes.STRING,
72
- allowNull: false
73
- },
74
- email: {
75
- type: DataTypes.STRING,
76
- allowNull: false
77
- },
78
- permissions_id: {
79
- type: DataTypes.INTEGER,
80
- allowNull: false
81
- },
82
- authkey: {
83
- type: DataTypes.STRING
84
- // allowNull defaults to true
85
- },
86
- status: {
87
- type: DataTypes.STRING
88
- // allowNull defaults to true
89
- }
90
- }
91
- }
92
-
93
- async findIdentityByAccessToken(token, type) {
94
-
95
- let decoded = JsonWebToken.decode(token, {complete: true})
96
- if(!decoded.payload.user) {
97
- return null;
98
- }
99
-
100
- let identity = await this.findOne({where: {id: parseInt(decoded.payload.user)}});
101
- if (identity) {
102
- BaseChyz.debug("Find Identity By AccessToken: User Found", decoded.payload)
103
- try {
104
- JsonWebToken.verify(token, identity.authkey);
105
- BaseChyz.debug("Find Identity By AccessToken: User Verify Success")
106
- return identity;
107
- } catch (err) {
108
- if (err.name == "TokenExpiredError")
109
- BaseChyz.debug("Find Identity By AccessToken: Token Expired")
110
- else
111
- BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
112
- return null;
113
- }
114
- }
115
- BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
116
- return null;
117
- }
118
-
119
-
120
-
121
-
122
- }
@@ -1,78 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
-
9
- require('dotenv-flow').config();
10
-
11
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
12
-
13
- import Chyz from "../Chyz";
14
- import {WebUser} from "../web/WebUser";
15
- import {KeycloakUser as Identity} from "./Models/KeycloakUser";
16
- // @ts-ignore
17
- import {DbConnection} from "../base/DbConnection";
18
-
19
- var Keycloak = require('keycloak-connect');
20
- var session = require('express-session');
21
- var memoryStore = new session.MemoryStore();
22
-
23
-
24
- var keycloakConfig = {
25
- "realm": "CameraBox",
26
- "auth-server-url": "https://keycloak.hubbox.io:8080/auth/",
27
- //"ssl-required": "external",
28
- "resource": "izanami",
29
- "verify-token-audience": true,
30
- "bearerOnly": true,
31
- "confidential-port":0,
32
- "policy-enforcer":{},
33
- "credentials": {
34
- "secret": "0b476571-28ab-49b1-9968-90fce6294d5a"
35
- }
36
-
37
- };
38
-
39
-
40
-
41
- Keycloak.prototype.accessDenied = function () {
42
- return null;
43
- }
44
-
45
- var keycloak = new Keycloak({scope: 'offline_access'}, keycloakConfig);
46
-
47
-
48
- let config = {
49
- port: 3000,
50
- controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
51
- components: {
52
- db: {
53
- class: DbConnection,
54
- database: process.env.DBDATABASE,
55
- username: process.env.DBUSER,
56
- password: process.env.DBPASS,
57
- options: {
58
- host: process.env.DBHOST,
59
- dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
60
- // disable logging; default: console.log
61
- logging: false
62
- }
63
- },
64
- user: {
65
- 'class': WebUser,
66
- 'identityClass': Identity
67
- }
68
- },
69
- middlewares: {
70
- keycloak: {
71
- keycloak: keycloak,
72
- config: {
73
- logout: '/logout'
74
- }
75
- }
76
- }
77
- }
78
- Chyz.app(config).Start();
package/Examples/index.ts DELETED
@@ -1,60 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
-
9
- // import {BaseChyz} from "../index";
10
- import Chyz from "../Chyz";
11
- import {WebUser} from "../web/WebUser";
12
- import {User} from "./Models/User";
13
- // import {DbConnection} from "../base";
14
- // import {AuthManager} from "../rbac/AuthManager";
15
-
16
- require('dotenv-flow').config();
17
-
18
-
19
-
20
- let config = {
21
- port: process.env.PORT,
22
- controllerpath: process.env.CONTROLLER_PATH,
23
- components: {
24
-
25
- // db: {
26
- // class: DbConnection,
27
- // database: process.env.DBDATABASE,
28
- // username: process.env.DBUSER,
29
- // password: process.env.DBPASS,
30
- //
31
- // options: {
32
- // host: process.env.DBHOST,
33
- // dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
34
- // // disable logging; default: console.log
35
- // logging: (msg: any) => BaseChyz.debug(msg)
36
- // }
37
- // },
38
- // db2: {
39
- // class: DbConnection,
40
- // database: process.env.DBDATABASE,
41
- // username: process.env.DBUSER,
42
- // password: process.env.DBPASS,
43
- // options: {
44
- // host: process.env.DBHOST,
45
- // dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
46
- // // disable logging; default: console.log
47
- // logging: (msg: any) => BaseChyz.debug('DB2', msg)
48
- // }
49
- // },
50
- // authManager: {
51
- // class: AuthManager,
52
- // },
53
- user: {
54
- 'class': WebUser,
55
- 'identityClass': User
56
- }
57
- }
58
-
59
- }
60
- Chyz.app(config).Start();
@@ -1,7 +0,0 @@
1
- {
2
- "realm": "quickstart",
3
- "bearer-only": true,
4
- "auth-server-url": "http://localhost:8180/auth",
5
- "ssl-required": "external",
6
- "resource": "service-nodejs"
7
- }
@@ -1,49 +0,0 @@
1
- {
2
- "name": "edis-manager-node",
3
- "version": "1.0.0",
4
- "description": "Entranet ve Erken Deprem Bildirim Sistemi (EDİS) entegrasyonu",
5
- "main": "index.js",
6
- "scripts": {
7
- "dev": "nodemon -x ts-node index.ts",
8
- "debug": "ts-node index.ts",
9
- "test": "echo \"Error: no test specified\" && exit 1"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/cihan53/edis-manager-node.git"
14
- },
15
- "author": "",
16
- "license": "MIT",
17
- "bugs": {
18
- "url": "https://github.com/cihan53/edis-manager-node/issues"
19
- },
20
- "homepage": "https://github.com/cihan53/edis-manager-node#readme",
21
- "dependencies": {
22
- "babel-plugin-transform-decorators-legacy": "^1.3.5",
23
- "bcrypt": "^5.0.1",
24
- "body-parser": "^1.19.0",
25
- "dotenv-flow": "^3.2.0",
26
- "express": "^4.17.1",
27
- "glob": "^7.1.7",
28
- "ioredis": "^4.28.5",
29
- "jsonwebtoken": "^8.5.1",
30
- "keycloak-connect": "^15.0.2",
31
- "lodash": "^4.17.21",
32
- "log4js": "^6.3.0",
33
- "method-override": "^3.0.0",
34
- "passport": "^0.4.1",
35
- "pg": "^8.7.1",
36
- "pg-hstore": "^2.3.4",
37
- "reflect-metadata": "^0.1.13",
38
- "sequelize": "^6.6.5",
39
- "sequelize-transparent-cache": "^2.3.0",
40
- "sequelize-transparent-cache-ioredis": "^2.3.0"
41
- },
42
- "devDependencies": {
43
- "@types/express": "^4.17.13",
44
- "@types/node": "^16.4.13",
45
- "nodemon": "^2.0.12",
46
- "ts-node": "^10.2.0",
47
- "typescript": "^4.3.5"
48
- }
49
- }
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES6",
4
- "experimentalDecorators": true,
5
- "emitDecoratorMetadata": true,
6
- // "isolatedModules": true,
7
- "removeComments": true,
8
- // "esModuleInterop": true,
9
- "allowSyntheticDefaultImports": true,
10
- "moduleResolution": "node"
11
- },
12
- "exclude": [
13
- "node_modules"
14
- ],
15
- "include": [
16
- "__tests__/**/*.ts",
17
- "Controllers/**/*.ts",
18
- "Models/**/*.ts",
19
- "environment.d.ts",
20
- ]
21
- }
@@ -1,71 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
- // @ts-ignore
8
- import {NextFunction, Request, Response} from "express";
9
- import Utils from "../requiments/Utils";
10
- import {Behavior} from "./Behavior";
11
-
12
- export class ActionFilter extends Behavior {
13
-
14
- public only: any;
15
-
16
- /**
17
- * @var array list of action IDs that this filter should not apply to.
18
- * @see only
19
- */
20
- public except = [];
21
-
22
-
23
- public init() {
24
-
25
- }
26
-
27
- public async beforeFilter(route: any, req: Request, res: Response) {
28
- if (!this.isActive(route)) {
29
- return;
30
- }
31
-
32
- await this.beforeAction(route, req, res)
33
- }
34
-
35
- protected isActive(action: any) {
36
- let id = action.id;
37
- let onlyMatch: boolean = false;
38
- let exceptMatch: boolean = false;
39
- if (Utils.isEmpty(this.only)) {
40
- onlyMatch = true;
41
- } else {
42
- onlyMatch = false;
43
- for (const onlyKey of this.only) {
44
- if (Utils.matchWildcard(action.id, onlyKey)) {
45
- onlyMatch = true;
46
- break;
47
- }
48
- }
49
- }
50
-
51
- for (const exceptKey in this.except) {
52
- let pattern = this.except[exceptKey];
53
- let match = id.match(pattern)
54
- if (match && match.length > 0) {
55
- exceptMatch = true;
56
- }
57
- }
58
-
59
- return !exceptMatch && onlyMatch;
60
- }
61
-
62
- /**
63
- * This method is invoked right before an action is to be executed (after all possible filters.)
64
- * You may override this method to do last-minute preparation for the action.
65
- * @param Action $action the action to be executed.
66
- * @return bool whether the action should continue to be executed.
67
- */
68
- public async beforeAction(route: any, req: Request, res: Response) {
69
- return true;
70
- }
71
- }
package/base/BaseError.ts DELETED
@@ -1,28 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- import Utils from "../requiments/Utils";
9
-
10
- export class BaseError extends Error {
11
- private statusCode: number;
12
-
13
- constructor(message: string,statusCode=500) {
14
- super(message);
15
- this.message= Utils.isString(message)?message: JSON.stringify(message);
16
- this.name = this.constructor.name // good practice
17
- this.statusCode = statusCode // error code for responding to client
18
- //Error.captureStackTrace(this)
19
- }
20
-
21
- toString(){
22
- return `${this.name}[${this.statusCode}] ${this.message}`
23
- }
24
- toJSON(){
25
- return {code: this?.statusCode, name: this.name, message: this.message}
26
- }
27
- }
28
-
@@ -1,19 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- import {Configurable} from "./Configurable";
9
- import BaseChyz from "../BaseChyz";
10
-
11
- export class BaseObject implements Configurable {
12
-
13
-
14
- public init() {
15
-
16
- BaseChyz.debug("BaseObject init.....",)
17
-
18
- }
19
- }
package/base/Behavior.ts DELETED
@@ -1,6 +0,0 @@
1
- import {BaseObject} from "./BaseObject";
2
-
3
- export class Behavior extends BaseObject
4
- {
5
-
6
- }
@@ -1,84 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- import {Component} from "./Component";
9
- import {RouteDefinition} from "../model/RouteDefinition";
10
- import {Request, Response} from "express";
11
-
12
- export class CWebController extends Component {
13
-
14
-
15
- /**
16
- * @var string the ID of this controller.
17
- */
18
- public id: string;
19
- public defaultAction = 'index';
20
-
21
- constructor(config: any) {
22
- super();
23
- this.id = this.constructor.name.replace("Controller", "").toLowerCase();
24
- }
25
-
26
- public init() {
27
- super.init();
28
- }
29
-
30
-
31
- /**
32
- * This method is invoked right before an action is executed.
33
- * @param $action
34
- */
35
- public async beforeAction(route: RouteDefinition, req: Request, res: Response) {
36
- if (route.id == "" || route.id == "/")
37
- this.id = this.defaultAction
38
-
39
- this.ensureBehaviors()
40
- for (const name of Object.keys(this.getBehaviors)) {
41
- await this.getBehaviors[name].beforeFilter(route, req, res);
42
- }
43
-
44
- }
45
-
46
- /**
47
- * This method is invoked right after an action is executed.
48
- * @param action
49
- */
50
- public afterAction(action: any, req: Request, res: Response) {
51
-
52
- }
53
-
54
- /**
55
- *
56
-
57
- Checks the privilege of the current user.
58
-
59
- This method should be overridden to check whether the current user has the privilege to run the specified action against the specified data model. If the user does not have access, a yii\web\ForbiddenHttpException should be thrown.
60
-
61
- */
62
- public checkAccess(action: any, model = null, params: any = []) {
63
-
64
- }
65
-
66
- /**
67
- * Send data formatted as JSON.
68
-
69
- This method is a shortcut for sending data formatted as JSON. It will return the response application component after configuring the format and setting the data that should be formatted. A common usage will b
70
- */
71
- asJson(data: any) {
72
-
73
- }
74
-
75
- /**
76
- * Send data formatted as XML.
77
-
78
- This method is a shortcut for sending data formatted as XML. It will return the response application component after configuring the format and setting the data that should be formatted. A common usage will be:
79
- */
80
- asXml(data: any) {
81
-
82
- }
83
-
84
- }
package/base/Component.ts DELETED
@@ -1,66 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- import {BaseObject} from "./BaseObject";
9
- import {ActionFilter} from "./ActionFilter";
10
- import Utils from "../requiments/Utils";
11
-
12
- export class Component extends BaseObject {
13
-
14
- /**
15
- * @var array the attached event handlers (event name => handlers)
16
- */
17
- private _events = [];
18
-
19
-
20
- /**
21
- * @var Behavior[]|null the attached behaviors (behavior name => behavior). This is `null` when not initialized.
22
- */
23
-
24
- private _behaviors: Array<ActionFilter> = [];
25
-
26
-
27
- /**
28
- * Returns a list of behaviors that this component should behave as.
29
- */
30
- public behaviors() {
31
- return [];
32
- }
33
-
34
-
35
- get getBehaviors(): any {
36
- return this._behaviors;
37
- }
38
-
39
- /**
40
- * Makes sure that the behaviors declared in [[behaviors()]] are attached to this component.
41
- */
42
- public ensureBehaviors() {
43
- if (this._behaviors.length == 0) {
44
- this._behaviors = [];
45
- if (this.behaviors().length > 0) {
46
- this.behaviors().forEach(behavior => {
47
- Object.keys(behavior).forEach((name: string) => {
48
- this.attachBehaviorInternal(name, behavior)
49
- });
50
- })
51
- }
52
-
53
- }
54
- }
55
-
56
-
57
- private attachBehaviorInternal(name: any, behavior: any) {
58
- if (!this._behaviors.hasOwnProperty(name)) {
59
- let beh = Utils.createObject(new behavior[name].class, behavior[name])
60
- beh.init()
61
- this._behaviors[name] = beh;
62
- }
63
- return behavior;
64
- }
65
-
66
- }
@@ -1,10 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
- export interface Configurable{
9
-
10
- }
@@ -1,16 +0,0 @@
1
- /*
2
- * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
- * Author: Cihan Ozturk
4
- * E-mail: cihan@chy.com.tr
5
- * Github:https://github.com/cihan53/
6
- */
7
-
8
-
9
-
10
- import {BaseError} from "./BaseError";
11
-
12
- export class DataErrorDbException extends BaseError {
13
- constructor ( public message: string) {
14
- super(message,502);
15
- }
16
- }