chyz 1.2.1-rc.2 → 1.2.4-rc.2

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 (201) hide show
  1. package/{dist/BaseChyz.js → BaseChyz.js} +0 -0
  2. package/{dist/BaseChyz.js.map → BaseChyz.js.map} +0 -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 -1
  58. package/filters/AccessControl.js.map +1 -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 +1 -1
  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 +2 -3
  72. package/{dist/filters → filters}/auth/JwtHttpBearerAuth.js.map +1 -1
  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} +3 -0
  80. package/{dist/index.js.map → index.js.map} +1 -1
  81. package/log/config/log4js.json +1 -1
  82. package/{dist/model → model}/RouteDefinition.js +0 -0
  83. package/{dist/model → model}/RouteDefinition.js.map +0 -0
  84. package/package.json +2 -2
  85. package/{dist/rbac → rbac}/AuthAssignment.js +0 -0
  86. package/{dist/rbac → rbac}/AuthAssignment.js.map +0 -0
  87. package/{dist/rbac → rbac}/AuthItem.js +0 -0
  88. package/{dist/rbac → rbac}/AuthItem.js.map +0 -0
  89. package/{dist/rbac → rbac}/AuthItemChild.js +0 -0
  90. package/{dist/rbac → rbac}/AuthItemChild.js.map +0 -0
  91. package/{dist/rbac → rbac}/AuthManager.js +0 -0
  92. package/{dist/rbac → rbac}/AuthManager.js.map +0 -0
  93. package/{dist/requiments → requiments}/Glob.js +0 -0
  94. package/{dist/requiments → requiments}/Glob.js.map +0 -0
  95. package/{dist/requiments → requiments}/ReflectUtil.js +0 -0
  96. package/{dist/requiments → requiments}/ReflectUtil.js.map +0 -0
  97. package/{dist/requiments → requiments}/Utils.js +0 -0
  98. package/{dist/requiments → requiments}/Utils.js.map +0 -0
  99. package/{dist/validators → validators}/BooleanValidator.js +0 -0
  100. package/{dist/validators → validators}/BooleanValidator.js.map +0 -0
  101. package/{dist/validators → validators}/CompareValidator.js +0 -0
  102. package/{dist/validators → validators}/CompareValidator.js.map +0 -0
  103. package/{dist/validators → validators}/DateValidator.js +0 -0
  104. package/{dist/validators → validators}/DateValidator.js.map +0 -0
  105. package/{dist/validators → validators}/EmailValidator.js +0 -0
  106. package/{dist/validators → validators}/EmailValidator.js.map +0 -0
  107. package/{dist/validators → validators}/Validator.js +0 -0
  108. package/{dist/validators → validators}/Validator.js.map +0 -0
  109. package/{dist/web → web}/IdentityInterface.js +0 -0
  110. package/{dist/web → web}/IdentityInterface.js.map +0 -0
  111. package/{dist/web → web}/WebUser.js +0 -0
  112. package/{dist/web → web}/WebUser.js.map +0 -0
  113. package/BaseChyz.ts +0 -454
  114. package/Chyz.ts +0 -11
  115. package/Doc/Moel kullanma.md +0 -13
  116. package/Examples/Controllers/ApiController.ts +0 -140
  117. package/Examples/Controllers/BasicApiController.ts +0 -121
  118. package/Examples/Controllers/KeyCloakController.ts +0 -100
  119. package/Examples/Controllers/PublicController.ts +0 -42
  120. package/Examples/Controllers/SiteController.ts +0 -149
  121. package/Examples/Models/AuthAssignment.ts +0 -50
  122. package/Examples/Models/AuthItem.ts +0 -59
  123. package/Examples/Models/AuthItemChild.ts +0 -49
  124. package/Examples/Models/Categories.ts +0 -51
  125. package/Examples/Models/Customer.ts +0 -115
  126. package/Examples/Models/KeycloakUser.ts +0 -70
  127. package/Examples/Models/Order.ts +0 -64
  128. package/Examples/Models/OrderItem.ts +0 -27
  129. package/Examples/Models/ProductModels.ts +0 -49
  130. package/Examples/Models/ProductToCategories.ts +0 -46
  131. package/Examples/Models/Products.ts +0 -50
  132. package/Examples/Models/Stocks.ts +0 -60
  133. package/Examples/Models/User.ts +0 -128
  134. package/Examples/Models/UserPermission.ts +0 -37
  135. package/Examples/Models/index.ts +0 -19
  136. package/Examples/index-keycloack.ts +0 -78
  137. package/Examples/index.ts +0 -60
  138. package/Examples/keycloak.json +0 -7
  139. package/Examples/log/access.log +0 -0
  140. package/Examples/log/app.log +0 -20601
  141. package/Examples/log/errors.log +0 -2120
  142. package/Examples/package.json +0 -49
  143. package/Examples/tsconfig.json +0 -21
  144. package/base/ActionFilter.ts +0 -71
  145. package/base/BaseError.ts +0 -28
  146. package/base/BaseObject.ts +0 -19
  147. package/base/Behavior.ts +0 -6
  148. package/base/CWebController.ts +0 -84
  149. package/base/Component.ts +0 -66
  150. package/base/Configurable.ts +0 -10
  151. package/base/DataErrorDbException.ts +0 -16
  152. package/base/DbConnection.ts +0 -55
  153. package/base/ForbiddenHttpException.ts +0 -15
  154. package/base/InvalidArgumentException.ts +0 -16
  155. package/base/InvalidConfigException.ts +0 -16
  156. package/base/Model.ts +0 -555
  157. package/base/ModelManager.ts +0 -19
  158. package/base/NotFoundHttpException.ts +0 -14
  159. package/base/RestClient.ts +0 -28
  160. package/base/UnauthorizedHttpException.ts +0 -17
  161. package/base/ValidationHttpException.ts +0 -14
  162. package/base/db/Exception.ts +0 -14
  163. package/base/index.ts +0 -18
  164. package/decorator/Middleware.ts +0 -9
  165. package/decorator/controller.ts +0 -22
  166. package/decorator/enums/ControllerDecoratorParams.ts +0 -5
  167. package/decorator/get.ts +0 -37
  168. package/decorator/index.ts +0 -3
  169. package/decorator/post.ts +0 -36
  170. package/dist/filters/AccessControl.js.map +0 -1
  171. package/dist/log/config/log4js.json +0 -55
  172. package/dist/package.json +0 -59
  173. package/filters/AccessControl.ts +0 -77
  174. package/filters/AccessRule.ts +0 -182
  175. package/filters/auth/AuthInterface.ts +0 -34
  176. package/filters/auth/AuthMethod.ts +0 -88
  177. package/filters/auth/HttpBasicAuth.ts +0 -75
  178. package/filters/auth/HttpBearerAuth.ts +0 -31
  179. package/filters/auth/HttpHeaderAuth.ts +0 -53
  180. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  181. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  182. package/filters/auth/index.ts +0 -4
  183. package/filters/index.ts +0 -2
  184. package/index.ts +0 -16
  185. package/model/RouteDefinition.ts +0 -18
  186. package/package-lock.json +0 -5259
  187. package/rbac/AuthAssignment.ts +0 -50
  188. package/rbac/AuthItem.ts +0 -57
  189. package/rbac/AuthItemChild.ts +0 -50
  190. package/rbac/AuthManager.ts +0 -398
  191. package/requiments/Glob.ts +0 -9
  192. package/requiments/ReflectUtil.ts +0 -26
  193. package/requiments/Utils.ts +0 -63
  194. package/tsconfig.json +0 -18
  195. package/validators/BooleanValidator.ts +0 -0
  196. package/validators/CompareValidator.ts +0 -0
  197. package/validators/DateValidator.ts +0 -0
  198. package/validators/EmailValidator.ts +0 -0
  199. package/validators/Validator.ts +0 -27
  200. package/web/IdentityInterface.ts +0 -68
  201. package/web/WebUser.ts +0 -187
@@ -1,121 +0,0 @@
1
- /*
2
- *
3
- * Copyright (c) 2021-2021.. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- *
8
- */
9
-
10
- import {CWebController, ForbiddenHttpException, ModelManager, ValidationHttpException} from "../../base";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {controller, get, post} from "../../decorator";
15
- import {ProductsClass} from "../Models/Products";
16
- import {HttpBasicAuth} from "../../filters/auth/HttpBasicAuth";
17
-
18
-
19
- @controller("/basic/api")
20
- class ApiController extends CWebController {
21
-
22
-
23
-
24
- public behaviors(): any[] {
25
-
26
- return [{
27
- 'authenticator': {
28
- "class": HttpBasicAuth,
29
- // "auth": this.myCheck
30
- }
31
- }]
32
- }
33
-
34
- @get("/")
35
- Index(req: Request, res: Response) {
36
-
37
- BaseChyz.logs().info("Site Controller Burası", this.id)
38
- return res.json({message: "index sayfası"})
39
- }
40
-
41
- @post("orderCreate")
42
- async Login(req: Request, res: Response) {
43
- let data = req.body;
44
- data.Customer.status = "true";
45
- data.Customer["2fa"] = "true";
46
-
47
- //Customer Model Create
48
- let customer = ModelManager.Customer.save();
49
- //Order Model Create
50
- let order = ModelManager.Order;
51
-
52
-
53
- let transaction
54
- try {
55
- // get transaction
56
- transaction = await BaseChyz.getComponent("db").transaction();
57
- customer.load(data, "Customer");//load customer data
58
- let cus: any = await customer.save({}, {transaction});
59
-
60
- if (!cus) {
61
- throw new ValidationHttpException(customer.errors);
62
- }
63
-
64
- data.Order.customer_id = cus.id;
65
- // data.Order.total = 0;
66
- // data.Order.status = true;
67
- order.load(data, "Order");
68
- let res1 = await order.save({}, {transaction});
69
- if (!res1) {
70
- throw new ValidationHttpException(order.errors);
71
- }
72
-
73
- // commit
74
- await transaction.commit();
75
-
76
- } catch (e) {
77
- if (transaction) {
78
- await transaction.rollback();
79
- BaseChyz.warn("Rollback transaction")
80
- }
81
-
82
- if (e instanceof ValidationHttpException)
83
- throw new ValidationHttpException(e.message)
84
- else
85
- throw new ForbiddenHttpException(e.message)
86
- }
87
- return res.send("Post Controller")
88
- }
89
-
90
-
91
- @get("order/list")
92
- async listOrder(req: Request, res: Response) {
93
- const {Products}: { Products: ProductsClass } = ModelManager;
94
- let product = await Products.findAll({include: [ModelManager.ProductModels.model()]});
95
- return res.json(product)
96
-
97
- }
98
-
99
- @get("categories")
100
- async Categories(req: Request, res: Response) {
101
- let product = await ModelManager.Categories.findAll({
102
- include: [
103
- {
104
- model: ModelManager.Products.model(),
105
- // as: 'product',
106
- // through: { attributes: [] } // Hide unwanted `PlayerGameTeam` nested object from results
107
- }
108
- ]
109
- });
110
- return res.json(product)
111
-
112
- }
113
-
114
-
115
- error(req: Request, res: Response) {
116
- BaseChyz.logs().info("Error Sayfası")
117
- return res.send("Post Controller")
118
- }
119
- }
120
-
121
- module.exports = ApiController
@@ -1,100 +0,0 @@
1
- /*
2
- *
3
- * Copyright (c) 2021-2021.. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- *
8
- */
9
-
10
- import {CWebController} from "../../base/CWebController";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {get,post,controller} from "../../decorator";
15
-
16
- import {ValidationHttpException,ForbiddenHttpException} from "../../base";
17
- import {KeyCloakHttpBearerAuth} from "../../filters/auth/KeyCloakHttpBearerAuth";
18
-
19
- import {OrderClass} from "../Models/Order";
20
- import {CustomerClass} from "../Models/Customer";
21
-
22
- @controller("/oauth2.0")
23
- class ApiController extends CWebController {
24
-
25
- public behaviors(): any[] {
26
-
27
- return [{
28
- 'authenticator': {
29
- "class": KeyCloakHttpBearerAuth,
30
- // "auth": this.myCheck
31
- }
32
- }]
33
- }
34
-
35
- @get("/")
36
- Index(req: Request, res: Response) {
37
-
38
- BaseChyz.logs().info("Site Controller Burası", this.id)
39
- return res.json({message: "index sayfası"})
40
- }
41
-
42
- @post("orderCreate")
43
- async Login(req: Request, res: Response) {
44
- let data = req.body;
45
- data.Customer.status = "true";
46
- data.Customer["2fa"] = "true";
47
-
48
- //Customer Model Create
49
- let customer: CustomerClass = new CustomerClass();
50
- //Order Model Create
51
- let order: OrderClass = new OrderClass() ;
52
-
53
-
54
- let transaction
55
- try {
56
- // get transaction
57
- transaction = await BaseChyz.getComponent("db").transaction();
58
-
59
-
60
- customer.load(data, "Customer");//load customer data
61
- let cus: any = await customer.save({}, {transaction});
62
-
63
- if (!cus) {
64
- throw new ValidationHttpException(customer.errors);
65
- }
66
-
67
- data.Order.customer_id = cus.id;
68
- // data.Order.total = 0;
69
- // data.Order.status = true;
70
- order.load(data, "Order");
71
- let res1 = await order.save({}, {transaction});
72
- if (!res1) {
73
- throw new ValidationHttpException(order.errors);
74
- }
75
-
76
- // commit
77
- await transaction.commit();
78
-
79
- } catch (e) {
80
- if (transaction) {
81
- await transaction.rollback();
82
- BaseChyz.warn("Rollback transaction")
83
- }
84
-
85
- if (e instanceof ValidationHttpException)
86
- throw new ValidationHttpException(e.message)
87
- else
88
- throw new ForbiddenHttpException(e.message)
89
- }
90
- return res.send("Post Controller")
91
- }
92
-
93
-
94
- error(req: Request, res: Response) {
95
- BaseChyz.logs().info("Error Sayfası")
96
- return res.send("Post Controller")
97
- }
98
- }
99
-
100
- module.exports = ApiController
@@ -1,42 +0,0 @@
1
- /*
2
- *
3
- * Copyright (c) 2021-2021.. Chy Bilgisayar Bilisim
4
- * Author: Cihan Ozturk
5
- * E-mail: cihan@chy.com.tr
6
- * Github:https://github.com/cihan53/
7
- *
8
- */
9
-
10
- import {CWebController} from "../../base/CWebController";
11
- import BaseChyz from "../../BaseChyz";
12
- // @ts-ignore
13
- import {Request, Response} from "express";
14
- import {get} from "../../decorator/get";
15
- import {controller} from "../../decorator/controller";
16
-
17
- @controller("/public")
18
- class PublicController extends CWebController {
19
-
20
- public myCheck(token) {
21
- console.log("myyyyyyyyyyyyyyyyyyyyy")
22
- }
23
-
24
- public behaviors(): any[] {
25
-
26
- return [ ]
27
- }
28
-
29
- @get("/")
30
- Index(req: Request, res: Response) {
31
-
32
- BaseChyz.logs().info("Site Controller Burası", super.id)
33
- return res.json({message: "index sayfası"})
34
- }
35
-
36
-
37
- error(req: Request, res: Response) {
38
- BaseChyz.logs().info("Error Sayfası")
39
- return res.send("Post Controller")
40
- }
41
- }
42
- module.exports=PublicController
@@ -1,149 +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 {CWebController} from "../../base";
9
- import BaseChyz from "../../BaseChyz";
10
- // @ts-ignore
11
- import {Request, Response} from "express";
12
- import {get} from "../../decorator";
13
- import {post} from "../../decorator";
14
- import {controller} from "../../decorator";
15
- import {User} from "../Models/User";
16
- import {ForbiddenHttpException} from "../../base";
17
- import {JwtHttpBearerAuth} from "../../filters/auth";
18
-
19
- const bcrypt = require('bcrypt');
20
- const JsonWebToken = require("jsonwebtoken");
21
-
22
-
23
- @controller("/site")
24
- class SiteController extends CWebController {
25
-
26
- public myCheck(token) {
27
- console.log("myyyyyyyyyyyyyyyyyyyyy")
28
- }
29
-
30
- public behaviors(): any[] {
31
- return [{
32
- 'authenticator': {
33
- "class": JwtHttpBearerAuth,
34
- "except": ["index", "login"]
35
- // "auth": this.myCheck
36
- }
37
- }]
38
- }
39
-
40
-
41
- // public behaviors(): any[] {
42
- //
43
- // return [{
44
- // // 'authenticator': {
45
- // // "class": JwtHttpBearerAuth,
46
- // // // "auth": this.myCheck
47
- // // },
48
- // 'access': {
49
- // 'class': AccessControl,
50
- // 'only': ['login', 'logout','index' ],
51
- // 'rules': [
52
- // {
53
- // 'allow': false,
54
- // 'actions': ['login', 'index' ],
55
- // 'roles': ['?'],
56
- // },
57
- // {
58
- // 'allow': true,
59
- // 'actions': ['logout', "logout2"],
60
- // 'roles': ['@'],
61
- // }
62
- // ]
63
- // }
64
- // }]
65
- // }
66
-
67
- @get("index")
68
- Index(req: Request, res: Response) {
69
-
70
- BaseChyz.logs().info("Site Controller Burası", this.id)
71
- return res.json({message: "index sayfası"})
72
- }
73
-
74
- @post("login")
75
- async login(req: Request, res: Response) {
76
- let UserModel: User = new User();
77
- let token
78
- let username = req.body.username;
79
- let password = req.body.password;
80
-
81
-
82
- let user = await UserModel.findOne({where: {username: username}})
83
- if (user) {
84
- BaseChyz.debug("Db found user", username)
85
- const match = await bcrypt.compare(password, user.password);
86
- if (match) {
87
- BaseChyz.debug("Db user verify", username)
88
- //login
89
- // @ts-ignore
90
- let xForwardedFor = (req.headers['x-forwarded-for'] || '').replace(/:\d+$/, '');
91
- let ip = xForwardedFor || req.socket.remoteAddress;
92
- var source: string = req.headers['user-agent'] || '';
93
- if (req.headers['x-ucbrowser-ua']) { //special case of UC Browser
94
- source = req.headers['x-ucbrowser-ua'] + "";
95
- }
96
- token = await JsonWebToken.sign({
97
- user: user.id,
98
- ip: ip,
99
- agent: source,
100
- platform: "admin",
101
- role: [
102
- "admin"
103
- ],
104
- permissions: [
105
- "xxxx",
106
-
107
- ],
108
- }, user.authkey, null);
109
-
110
- BaseChyz.debug("Db user create access token", username, "expiresIn", "1h")
111
- return res.json({token: token})
112
- } else {
113
- let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
114
- res.status(500).json(error.toJSON())
115
- }
116
- } else {
117
- let error: any = new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'))
118
- res.status(500).json(error.toJSON())
119
- }
120
-
121
-
122
- }
123
-
124
- @get("logout")
125
- logout(req: Request, res: Response) {
126
-
127
- // @ts-ignore
128
- let identity = req.user ?? BaseChyz.getComponent("user").getIdentity();
129
- // console.log("logout2", identity.id)
130
- //console.log(identity)
131
-
132
- BaseChyz.logs().info("Logout Controller")
133
- return res.send("Logout Controller")
134
- }
135
-
136
- @get("signup")
137
- logout2(req: Request, res: Response) {
138
-
139
-
140
- return res.send("Logout Controller")
141
- }
142
-
143
- error(req: Request, res: Response) {
144
- BaseChyz.logs().info("Error Sayfası")
145
- return res.send("Post Controller")
146
- }
147
- }
148
-
149
- module.exports = SiteController
@@ -1,50 +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 {DataTypes, Model, ModelManager, Relation} from "../../base";
9
-
10
- export class AuthAssignmentClass extends Model {
11
- [x: string]: any;
12
-
13
- tableName() {
14
- return 'auth_assignment';
15
- }
16
- attributes() {
17
- return {
18
-
19
- // Model attributes are defined here
20
- item_name: {
21
- type: DataTypes.STRING,
22
- primaryKey:true,
23
- allowNull: false
24
- },
25
- user_id : {
26
- type: DataTypes.STRING,
27
- allowNull: false
28
- }
29
-
30
- }
31
- }
32
-
33
- init(){
34
- super.init();
35
- this.model().removeAttribute('id')
36
- }
37
-
38
- relations(): Relation[] {
39
- return [
40
- {
41
- type: "hasMany",
42
- foreignKey: "name",
43
- sourceKey:'item_name',
44
- model: ModelManager.AuthItem.model()
45
- }
46
- ]
47
- }
48
-
49
- }
50
-
@@ -1,59 +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 {DataTypes, Model, ModelManager, Relation} from "../../base";
11
-
12
- export class AuthItemClass extends Model {
13
- [x: string]: any;
14
-
15
- tableName() {
16
- return 'auth_item';
17
- }
18
-
19
- attributes() {
20
- return {
21
- // Model attributes are defined here
22
- name: {
23
- type: DataTypes.STRING,
24
- primaryKey:true,
25
- allowNull: false
26
- },
27
- type: {
28
- type: DataTypes.INTEGER,
29
- allowNull: false
30
- },
31
- description: {
32
- type: DataTypes.STRING,
33
- allowNull: false
34
- },
35
- rule_name: {
36
- type: DataTypes.STRING,
37
- allowNull: false
38
- }
39
-
40
- }
41
- }
42
-
43
- init() {
44
- super.init();
45
- this.model().removeAttribute('id')
46
- }
47
-
48
- // relations(): Relation[] {
49
- // return [
50
- // {
51
- // type: "hasOne",
52
- // foreignKey: "item_name",
53
- // model: ModelManager.AuthAssignment.model()
54
- // }
55
- // ]
56
- // }
57
-
58
- }
59
-
@@ -1,49 +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 {DataTypes, Model, ModelManager, Relation} from "../../base";
10
-
11
- export class AuthItemChildClass extends Model {
12
- [x: string]: any;
13
-
14
- tableName() {
15
- return 'auth_item_child';
16
- }
17
-
18
- attributes() {
19
- return {
20
- // Model attributes are defined here
21
- parent: {
22
- type: DataTypes.STRING,
23
- primaryKey: true,
24
- allowNull: false
25
- },
26
- child: {
27
- type: DataTypes.STRING,
28
- allowNull: false
29
- }
30
- }
31
- }
32
-
33
- init() {
34
- super.init();
35
- this.model().removeAttribute('id')
36
- }
37
-
38
- relations(): Relation[] {
39
- return [
40
- {
41
- type: "hasOne",
42
- foreignKey: "item_name",
43
- model: ModelManager.AuthAssignment.model()
44
- }
45
- ]
46
- }
47
-
48
- }
49
-
@@ -1,51 +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
- import {DataTypes, Model, ModelManager, Relation} from "../../base";
8
- import {BaseChyz} from "../../index";
9
-
10
- export class CategoriesClass extends Model {
11
- [x: string]: any;
12
-
13
- constructor( ) {
14
- super(BaseChyz.getComponent("db2").db);
15
- }
16
- tableName() {
17
- return 'categories';
18
- }
19
-
20
-
21
- attributes() {
22
- return {
23
- // Model attributes are defined here
24
- title: {
25
- type: DataTypes.STRING,
26
- allowNull: false
27
- },
28
- properties: {
29
- type: DataTypes.STRING,
30
- allowNull: false
31
- }
32
-
33
- }
34
- }
35
-
36
- relations(): Relation[] {
37
- return [
38
- {
39
- type: "belongsToMany",
40
- foreignKey: "category_id",
41
- sourceKey: "id",
42
- model: ModelManager.Products.model(),
43
- through: ModelManager.ProductToCategories.model()
44
- }
45
- ]
46
- }
47
-
48
- }
49
-
50
- // const Categories = new CategoriesClass();
51
- // export {Categories};