chyz 1.2.4-rc.1 → 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 (179) 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 -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 +2 -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/log/config/log4js.json +0 -55
  150. package/dist/package.json +0 -59
  151. package/filters/AccessControl.ts +0 -74
  152. package/filters/AccessRule.ts +0 -182
  153. package/filters/auth/AuthInterface.ts +0 -34
  154. package/filters/auth/AuthMethod.ts +0 -89
  155. package/filters/auth/HttpBasicAuth.ts +0 -75
  156. package/filters/auth/HttpBearerAuth.ts +0 -31
  157. package/filters/auth/HttpHeaderAuth.ts +0 -53
  158. package/filters/auth/JwtHttpBearerAuth.ts +0 -80
  159. package/filters/auth/KeyCloakHttpBearerAuth.ts +0 -115
  160. package/filters/auth/index.ts +0 -4
  161. package/filters/index.ts +0 -2
  162. package/index.ts +0 -16
  163. package/model/RouteDefinition.ts +0 -18
  164. package/package-lock.json +0 -5259
  165. package/rbac/AuthAssignment.ts +0 -50
  166. package/rbac/AuthItem.ts +0 -57
  167. package/rbac/AuthItemChild.ts +0 -50
  168. package/rbac/AuthManager.ts +0 -398
  169. package/requiments/Glob.ts +0 -9
  170. package/requiments/ReflectUtil.ts +0 -26
  171. package/requiments/Utils.ts +0 -63
  172. package/tsconfig.json +0 -18
  173. package/validators/BooleanValidator.ts +0 -0
  174. package/validators/CompareValidator.ts +0 -0
  175. package/validators/DateValidator.ts +0 -0
  176. package/validators/EmailValidator.ts +0 -0
  177. package/validators/Validator.ts +0 -27
  178. package/web/IdentityInterface.ts +0 -68
  179. package/web/WebUser.ts +0 -187
package/BaseChyz.ts DELETED
@@ -1,454 +0,0 @@
1
- import 'reflect-metadata';
2
- import {RouteDefinition} from "./model/RouteDefinition";
3
- import {NextFunction, Request, Response} from "express";
4
- import {CWebController} from "./base";
5
- import Utils from "./requiments/Utils";
6
- import {ModelManager} from "./base";
7
-
8
-
9
- const https = require('https');
10
- const express = require("express");
11
- const log4js = require("log4js");
12
- const fs = require('fs');
13
- const validate = require('validate.js');
14
-
15
- /**
16
- * Use
17
- * selectedBox: {
18
- * array: {
19
- * id: {
20
- * numericality: {
21
- * onlyInteger: true,
22
- * greaterThan: 0
23
- * }
24
- * }
25
- * }
26
- * },
27
- * @param arrayItems
28
- * @param itemConstraints
29
- */
30
- validate.validators.array = (arrayItems: any, itemConstraints: any) => {
31
- const arrayItemErrors = arrayItems.reduce((errors: any, item: any, index: any) => {
32
- const error = validate(item, itemConstraints);
33
- if (error) errors[index] = {error: error};
34
- return errors;
35
- }, {});
36
-
37
- return Utils.isEmpty(arrayItemErrors) ? null : {errors: arrayItemErrors};
38
- };
39
-
40
-
41
- validate.validators.tokenString = (items: any, itemConstraints: any) => {
42
- let arrayItems = items.split(",");
43
- const arrayItemErrors = arrayItems.reduce((errors: any, item: any, index: any) => {
44
- const error = validate(item, itemConstraints);
45
- if (error) errors[index] = {error: error};
46
- return errors;
47
- }, {});
48
-
49
- return Utils.isEmpty(arrayItemErrors) ? null : {errors: arrayItemErrors};
50
- };
51
-
52
- var ip = require('ip');
53
- var bodyParser = require('body-parser')
54
- var methodOverride = require('method-override')
55
-
56
- export {Request, Response, NextFunction} from "express";
57
- export default class BaseChyz {
58
- private config: any;
59
- static app: string;
60
- static httpServer: any;
61
- static express = express()
62
- private _port: number = 3001;
63
- static db: any;
64
- static routes: any;
65
- private static _validate: any = validate;
66
- private _logConfig: any = require('./log/config/log4js.json') ?? {}
67
- private _controllerpath: string = "Controllers"
68
- private static controllers: Array<CWebController> = []
69
- public static components: any = {}
70
- public static middlewares: any = {}
71
-
72
-
73
- get logConfig(): any {
74
- return this._logConfig;
75
- }
76
-
77
- set logConfig(value: any) {
78
- this._logConfig = value;
79
- }
80
-
81
- get controllerpath(): string {
82
- return this._controllerpath;
83
- }
84
-
85
- set controllerpath(value: string) {
86
- this._controllerpath = value;
87
- }
88
-
89
- init() {
90
-
91
-
92
- /**
93
- * set request id
94
- */
95
- Object.defineProperty(BaseChyz.express.request, 'reqId', {
96
- configurable: true,
97
- enumerable: true,
98
- writable: true
99
- })
100
-
101
- Object.defineProperty(BaseChyz.express.request, 'user', {
102
- configurable: true,
103
- enumerable: true,
104
- writable: true
105
- })
106
-
107
- Object.defineProperty(BaseChyz.express.request, 'identity', {
108
- configurable: true,
109
- enumerable: true,
110
- writable: true
111
- })
112
-
113
-
114
- /**
115
- * server port setting
116
- */
117
- if (this.config.hasOwnProperty("port"))
118
- this.port = this.config.port;
119
-
120
- /**
121
- * controller path
122
- */
123
- if (this.config.controllerpath) {
124
- this.controllerpath = this.config.controllerpath
125
- }
126
-
127
-
128
- /**
129
- * Model Register
130
- */
131
-
132
- this.loadModels();
133
-
134
- /**
135
- * Express Server
136
- */
137
- this.middleware()
138
-
139
- /**
140
- * Load Controller
141
- */
142
- this.loadController();
143
-
144
-
145
- }
146
-
147
- /**
148
- * Listen port number
149
- * Server port number get
150
- */
151
- get port(): number {
152
- return this._port;
153
- }
154
-
155
- /**
156
- * Listen port number
157
- * Server port number setting
158
- * @param value
159
- */
160
- set port(value: number) {
161
- this._port = value;
162
- }
163
-
164
-
165
- static get validate(): any {
166
- return this._validate;
167
- }
168
-
169
- static set validate(value: any) {
170
- this._validate = value;
171
- }
172
-
173
- app(config: any = {}): BaseChyz {
174
-
175
- /**
176
- * Config set
177
- */
178
- this.config = config;
179
-
180
-
181
- // logger setting
182
- this.logProvider().level = log4js.levels.ALL;
183
- this.logProvider().configure(this._logConfig);
184
-
185
- let components = Utils.findKeyValue(config, "components")
186
- if (components) {
187
- for (const componentsKey in components) {
188
-
189
- let comp = components[componentsKey];
190
- BaseChyz.debug("Create Component ", componentsKey)
191
- try {
192
- BaseChyz.components[componentsKey] = Utils.createObject(new comp.class, comp);
193
- BaseChyz.components[componentsKey]?.init();
194
- } catch (e) {
195
- BaseChyz.error("Create Component Error", e)
196
- }
197
-
198
- }
199
- }
200
-
201
-
202
- let middlewares = Utils.findKeyValue(config, "middlewares")
203
- if (middlewares) {
204
- for (const middlewareKey in middlewares) {
205
- let middleware1 = middlewares[middlewareKey];
206
- BaseChyz.logs().debug("Create middlewares ", middlewareKey)
207
- BaseChyz.middlewares[middlewareKey] = middleware1;
208
- // BaseChyz.middlewares[middlewareKey] = Utils.createObject(new middleware1.class, middleware1);
209
- }
210
- }
211
-
212
- this.init();
213
-
214
- return this;
215
- }
216
-
217
-
218
- public logProvider() {
219
- return log4js;
220
- }
221
-
222
- public getLogger() {
223
- return this.logProvider().getLogger(this.constructor.name);
224
- }
225
-
226
- static logs(...args: any[]) {
227
- return log4js.getLogger(this.name);
228
- }
229
-
230
- public static trace(...args: any[]) {
231
- BaseChyz.logs().fatal(...arguments)
232
- }
233
-
234
- public static debug(...args: any[]) {
235
- BaseChyz.logs().debug(...arguments)
236
- }
237
-
238
- public static info(...args: any[]) {
239
- BaseChyz.logs().info(...arguments)
240
- }
241
-
242
- public static warn(...args: any[]) {
243
- BaseChyz.logs().warn(...arguments)
244
- }
245
-
246
- public static error(...args: any[]) {
247
- BaseChyz.logs().error(...arguments)
248
- }
249
-
250
- public static fatal(...args: any[]) {
251
- BaseChyz.logs().fatal(...arguments)
252
- }
253
-
254
-
255
- public static warning(...args: any[]) {
256
- BaseChyz.logs().warn(...arguments)
257
- }
258
-
259
- public static t(text: string) {
260
- return text;
261
- }
262
-
263
-
264
- public errorLogger(error: any, req: any, res: any, next: any) { // for logging errors
265
- BaseChyz.error(error)
266
- next(error) // forward to next middleware
267
- }
268
-
269
- public errorResponder(error: any, req: any, res: any, next: any) { // responding to client
270
- if (error.type == 'redirect')
271
- res.redirect('/error')
272
- else if (error.type == 'time-out') // arbitrary condition check
273
- res.status(408).json(error)
274
- else
275
- next(error) // forwarding exceptional case to fail-safe middleware
276
- }
277
-
278
-
279
- public errorHandler(err: any, req: any, res: any, next: any) {
280
- if (res.headersSent) {
281
- return next(err)
282
- }
283
-
284
- res.status(500).json({error: err})
285
- }
286
-
287
- public static getComponent(key: any) {
288
- return BaseChyz.components[key] ?? null
289
- }
290
-
291
-
292
- public static getMiddlewares(key: any) {
293
- return BaseChyz.middlewares[key] ?? null
294
- }
295
-
296
- /**
297
- * load model
298
- */
299
- async loadModels() {
300
- let models: any = {}
301
- let path = `${this._controllerpath}/../Models`;
302
- fs.readdirSync(path).forEach((file: string) => {
303
- if (file !== "index.ts") {
304
- let model = require(`${path}/${file}`);
305
- // @ts-ignore
306
- let className = file.split(".")[0] + "Class";
307
- if (model[className])
308
- models[className.replace("Class", "")] = new model[className];
309
- }
310
- })
311
-
312
- ModelManager._register(models);
313
-
314
- for (const key of Object.keys(ModelManager)) {
315
- if (key != "_register") {
316
- ModelManager[key].init();
317
- }
318
- }
319
- }
320
-
321
- /**
322
- * load contoller
323
- */
324
- async loadController() {
325
- let articlesEndpoints: string[] = [];
326
- fs.readdirSync(`${this._controllerpath}/`).forEach((file: string) => {
327
- let controller = require(`${this._controllerpath}/${file}`);
328
-
329
- // This is our instantiated class
330
- const instance: CWebController = new controller();
331
-
332
- BaseChyz.controllers.push(instance);
333
-
334
- // The prefix saved to our controller
335
- // @ts-ignore
336
- const prefix = Reflect.getMetadata('prefix', controller);
337
- // Our `routes` array containing all our routes for this controller
338
- // @ts-ignore
339
- const routes: Array<RouteDefinition> = Reflect.getMetadata('routes', controller);
340
- BaseChyz.logs().debug("Controller load ", controller.name, `(${prefix})`)
341
-
342
- if (routes) {
343
- routes.forEach(route => {
344
-
345
- let actionId = route.path == "/" || route.path == "" ? instance.defaultAction : route.path;
346
- route.id = actionId;
347
- BaseChyz.logs().debug("Controller route Path", prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`))
348
-
349
- BaseChyz.express[route.requestMethod](prefix + (route.path.startsWith("/") ? route.path : `/${route.path}`),
350
- async (req: Request, res: Response, next: NextFunction) => {
351
- try {
352
- BaseChyz.debug(`Call Request id ${instance.id}`)
353
- await instance.beforeAction(route, req, res)
354
- next()
355
- } catch (e: any) {
356
- BaseChyz.error(e);
357
-
358
- res.status(e.statusCode || 500)
359
- res.json({error: {code: e.statusCode || 500, name: e.name, message: e.message}})
360
- // next(e)
361
- }
362
-
363
- },
364
- async (req: Request, res: Response, next: NextFunction) => {
365
- try {
366
- // @ts-ignore
367
- BaseChyz.debug("Request ID ", req.reqId)
368
- // @ts-ignore
369
- await instance[route.methodName](req, res, next);
370
- instance.afterAction(route, req, res);
371
- } catch (e) {
372
- if (e instanceof Error) {
373
- BaseChyz.error(e)
374
-
375
- // @ts-ignore
376
- res.status(e.statusCode || 500)
377
- // @ts-ignore
378
- res.json({error: {code: e.statusCode || 500, name: e.name, message: e.message}})
379
- } else {
380
- res.json(e)
381
- }
382
- }
383
- })
384
-
385
-
386
- });
387
- }
388
- })
389
- }
390
-
391
- public middleware() {
392
-
393
- BaseChyz.express.use(bodyParser.json({limit: '1mb'}));
394
- BaseChyz.express.use(bodyParser.urlencoded({limit: '1mb', extended: true})); // support encoded bodies
395
- BaseChyz.express.use(methodOverride());
396
- BaseChyz.express.use(methodOverride());
397
-
398
-
399
- // CORS
400
- BaseChyz.express.use(function (req: any, res: Response, next: any) {
401
- // @ts-ignore
402
- req.reqId = Utils.uniqueId("chyzzzz_")
403
- res.setHeader('Content-Type', 'application/json');
404
- res.setHeader("Access-Control-Allow-Origin", "*");
405
- res.setHeader("Access-Control-Allow-Credentials", "true");
406
- res.setHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
407
- res.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Origin,Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers,Authorization");
408
- next();
409
- });
410
-
411
- //Middlewares
412
- for (const middleware1 of Object.keys(BaseChyz.middlewares)) {
413
- if (!Utils.isFunction(middleware1)) {
414
- let keycloak = BaseChyz.middlewares[middleware1].keycloak;
415
- BaseChyz.express.use(keycloak.middleware(BaseChyz.middlewares[middleware1].config));
416
- } else {
417
- BaseChyz.express.use(BaseChyz.middlewares[middleware1]);
418
- }
419
-
420
- }
421
-
422
-
423
- BaseChyz.express.use(this.errorResponder)
424
- BaseChyz.express.use(this.errorHandler)
425
- }
426
-
427
-
428
- public Start() {
429
-
430
- BaseChyz.info("Express Server Starting")
431
-
432
- if (this.config?.ssl) {
433
- BaseChyz.httpServer = https.createServer(this.config?.ssl, BaseChyz.express);
434
- BaseChyz.httpServer.listen(this._port, () => {
435
- BaseChyz.info("Express Server Start ")
436
- BaseChyz.info(`Liten Port ${this._port}`)
437
- BaseChyz.info(`https://localhost:${this._port}`)
438
- BaseChyz.info(`https://${ip.address()}:${this._port}`)
439
- })
440
- } else {
441
- BaseChyz.httpServer = BaseChyz.express.listen(this._port, () => {
442
- BaseChyz.info("Express Server Start ")
443
- BaseChyz.info(`Liten Port ${this._port}`)
444
- BaseChyz.info(`http://localhost:${this._port}`)
445
- BaseChyz.info(`http://${ip.address()}:${this._port}`)
446
- })
447
- }
448
-
449
-
450
- return this;
451
- }
452
-
453
-
454
- }
package/Chyz.ts DELETED
@@ -1,11 +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 BaseChyz from "./BaseChyz";
9
- const Chyz = new BaseChyz();
10
-
11
- export default Chyz;
package/Doc/Git.md DELETED
@@ -1,29 +0,0 @@
1
-
2
-
3
- Deleting the .git folder may cause problems in your git repository. If you want to delete all your commit history but keep the code in its current state, it is very safe to do it as in the following:
4
-
5
- ###Checkout
6
-
7
- git checkout --orphan latest_branch
8
-
9
- ###Add all the files
10
-
11
- git add -A
12
-
13
- ###Commit the changes
14
-
15
- git commit -am "commit message"
16
-
17
- ###Delete the branch
18
-
19
- git branch -D main
20
-
21
- ###Rename the current branch to main
22
-
23
- git branch -m main
24
-
25
- ###Finally, force update your repository
26
-
27
- git push -f origin main
28
-
29
- PS: this will not keep your old commit history around
@@ -1,13 +0,0 @@
1
- ##Model
2
-
3
- Model sınıfı "Sequelize" üzerine inşa edildmiştir ( ileriki zamanlarda farklı yöntemlerde eklemeyi planlıyorum)
4
-
5
- ##public function
6
-
7
- ###getDb:
8
- ###get sequelize:
9
- ###set sequelize:
10
- ###get errors:
11
- ###set errors:
12
- ###init:
13
-
@@ -1,110 +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 {JwtHttpBearerAuth} from "../../filters/auth";
16
-
17
-
18
- @controller("/api")
19
- class ApiController extends CWebController {
20
-
21
- public myCheck(token) {
22
- console.log("myyyyyyyyyyyyyyyyyyyyy")
23
- }
24
-
25
- public behaviors(): any[] {
26
-
27
- return [{
28
- 'authenticator': {
29
- "class": JwtHttpBearerAuth,
30
- // "auth": this.myCheck
31
- },
32
- // 'access': {
33
- // 'class': AccessControl,
34
- // 'only': ['order/list' ],
35
- // 'rules': [
36
- //
37
- // {
38
- // 'allow': true,
39
- // 'actions': ['order/list' ],
40
- // 'roles': ['edis-manager'],
41
- // }
42
- // ]
43
- // }
44
- }]
45
- }
46
-
47
- @get("/")
48
- Index(req: Request, res: Response) {
49
-
50
- BaseChyz.logs().info("Site Controller Burası", this.id)
51
- return res.json({message: "index sayfası"})
52
- }
53
-
54
- @post("orderCreate")
55
- async Login(req: Request, res: Response) {
56
- let data = req.body;
57
- data.Customer.status = "true";
58
- data.Customer["2fa"] = "true";
59
-
60
- //Customer Model Create
61
- let customer = ModelManager.Customer.save();
62
- //Order Model Create
63
- let order = ModelManager.Order;
64
-
65
-
66
- let transaction
67
- try {
68
- // get transaction
69
- transaction = await BaseChyz.getComponent("db").transaction();
70
- customer.load(data, "Customer");//load customer data
71
- let cus: any = await customer.save({}, {transaction});
72
-
73
- if (!cus) {
74
- throw new ValidationHttpException(customer.errors);
75
- }
76
-
77
- data.Order.customer_id = cus.id;
78
- // data.Order.total = 0;
79
- // data.Order.status = true;
80
- order.load(data, "Order");
81
- let res1 = await order.save({}, {transaction});
82
- if (!res1) {
83
- throw new ValidationHttpException(order.errors);
84
- }
85
-
86
- // commit
87
- await transaction.commit();
88
-
89
- } catch (e) {
90
- if (transaction) {
91
- await transaction.rollback();
92
- BaseChyz.warn("Rollback transaction")
93
- }
94
-
95
- if (e instanceof ValidationHttpException)
96
- throw new ValidationHttpException(e.message)
97
- else
98
- throw new ForbiddenHttpException(e.message)
99
- }
100
- return res.send("Post Controller")
101
- }
102
-
103
-
104
- error(req: Request, res: Response) {
105
- BaseChyz.logs().info("Error Sayfası")
106
- return res.send("Post Controller")
107
- }
108
- }
109
-
110
- module.exports = ApiController