chyz 1.2.1-rc.0 → 1.2.1-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.
- package/BaseChyz.ts +454 -0
- package/Chyz.ts +11 -0
- package/Doc/Moel kullanma.md +13 -0
- package/Examples/Controllers/ApiController.ts +140 -0
- package/Examples/Controllers/BasicApiController.ts +121 -0
- package/Examples/Controllers/KeyCloakController.ts +100 -0
- package/Examples/Controllers/PublicController.ts +42 -0
- package/Examples/Controllers/SiteController.ts +149 -0
- package/Examples/Models/AuthAssignment.ts +50 -0
- package/Examples/Models/AuthItem.ts +59 -0
- package/Examples/Models/AuthItemChild.ts +49 -0
- package/Examples/Models/Categories.ts +51 -0
- package/Examples/Models/Customer.ts +115 -0
- package/Examples/Models/KeycloakUser.ts +70 -0
- package/Examples/Models/Order.ts +64 -0
- package/Examples/Models/OrderItem.ts +27 -0
- package/Examples/Models/ProductModels.ts +49 -0
- package/Examples/Models/ProductToCategories.ts +46 -0
- package/Examples/Models/Products.ts +50 -0
- package/Examples/Models/Stocks.ts +60 -0
- package/Examples/Models/User.ts +128 -0
- package/Examples/Models/UserPermission.ts +37 -0
- package/Examples/Models/index.ts +19 -0
- package/Examples/index-keycloack.ts +78 -0
- package/Examples/index.ts +60 -0
- package/Examples/keycloak.json +7 -0
- package/Examples/log/access.log +0 -0
- package/Examples/log/app.log +20601 -0
- package/Examples/log/errors.log +2120 -0
- package/Examples/package.json +49 -0
- package/Examples/tsconfig.json +21 -0
- package/README.md +518 -0
- package/base/ActionFilter.ts +71 -0
- package/base/BaseError.ts +28 -0
- package/base/BaseObject.ts +19 -0
- package/base/Behavior.ts +6 -0
- package/base/CWebController.ts +84 -0
- package/base/Component.ts +66 -0
- package/base/Configurable.ts +10 -0
- package/base/DataErrorDbException.ts +16 -0
- package/base/DbConnection.ts +55 -0
- package/base/ForbiddenHttpException.ts +15 -0
- package/base/InvalidArgumentException.ts +16 -0
- package/base/InvalidConfigException.ts +16 -0
- package/base/Model.ts +555 -0
- package/base/ModelManager.ts +19 -0
- package/base/NotFoundHttpException.ts +14 -0
- package/base/RestClient.ts +28 -0
- package/base/UnauthorizedHttpException.ts +17 -0
- package/base/ValidationHttpException.ts +14 -0
- package/base/db/Exception.ts +14 -0
- package/base/index.ts +18 -0
- package/decorator/Middleware.ts +9 -0
- package/decorator/controller.ts +22 -0
- package/decorator/enums/ControllerDecoratorParams.ts +5 -0
- package/decorator/get.ts +37 -0
- package/decorator/index.ts +3 -0
- package/decorator/post.ts +36 -0
- package/{BaseChyz.js → dist/BaseChyz.js} +0 -0
- package/{BaseChyz.js.map → dist/BaseChyz.js.map} +0 -0
- package/{Chyz.js → dist/Chyz.js} +0 -0
- package/{Chyz.js.map → dist/Chyz.js.map} +0 -0
- package/{base → dist/base}/ActionFilter.js +0 -0
- package/{base → dist/base}/ActionFilter.js.map +0 -0
- package/{base → dist/base}/BaseError.js +0 -0
- package/{base → dist/base}/BaseError.js.map +0 -0
- package/{base → dist/base}/BaseObject.js +0 -0
- package/{base → dist/base}/BaseObject.js.map +0 -0
- package/{base → dist/base}/Behavior.js +0 -0
- package/{base → dist/base}/Behavior.js.map +0 -0
- package/{base → dist/base}/CWebController.js +0 -0
- package/{base → dist/base}/CWebController.js.map +0 -0
- package/{base → dist/base}/Component.js +0 -0
- package/{base → dist/base}/Component.js.map +0 -0
- package/{base → dist/base}/Configurable.js +0 -0
- package/{base → dist/base}/Configurable.js.map +0 -0
- package/{base → dist/base}/DataErrorDbException.js +0 -0
- package/{base → dist/base}/DataErrorDbException.js.map +0 -0
- package/{base → dist/base}/DbConnection.js +0 -0
- package/{base → dist/base}/DbConnection.js.map +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js +0 -0
- package/{base → dist/base}/ForbiddenHttpException.js.map +0 -0
- package/{base → dist/base}/InvalidArgumentException.js +0 -0
- package/{base → dist/base}/InvalidArgumentException.js.map +0 -0
- package/{base → dist/base}/InvalidConfigException.js +0 -0
- package/{base → dist/base}/InvalidConfigException.js.map +0 -0
- package/{base → dist/base}/Model.js +0 -0
- package/{base → dist/base}/Model.js.map +0 -0
- package/{base → dist/base}/ModelManager.js +0 -0
- package/{base → dist/base}/ModelManager.js.map +0 -0
- package/{base → dist/base}/NotFoundHttpException.js +0 -0
- package/{base → dist/base}/NotFoundHttpException.js.map +0 -0
- package/{base → dist/base}/RestClient.js +0 -0
- package/{base → dist/base}/RestClient.js.map +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js +0 -0
- package/{base → dist/base}/UnauthorizedHttpException.js.map +0 -0
- package/{base → dist/base}/ValidationHttpException.js +0 -0
- package/{base → dist/base}/ValidationHttpException.js.map +0 -0
- package/{base → dist/base}/db/Exception.js +0 -0
- package/{base → dist/base}/db/Exception.js.map +0 -0
- package/{base → dist/base}/index.js +0 -0
- package/{base → dist/base}/index.js.map +0 -0
- package/{decorator → dist/decorator}/Middleware.js +0 -0
- package/{decorator → dist/decorator}/Middleware.js.map +0 -0
- package/{decorator → dist/decorator}/controller.js +0 -0
- package/{decorator → dist/decorator}/controller.js.map +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js +0 -0
- package/{decorator → dist/decorator}/enums/ControllerDecoratorParams.js.map +0 -0
- package/{decorator → dist/decorator}/get.js +0 -0
- package/{decorator → dist/decorator}/get.js.map +0 -0
- package/{decorator → dist/decorator}/index.js +0 -0
- package/{decorator → dist/decorator}/index.js.map +0 -0
- package/{decorator → dist/decorator}/post.js +0 -0
- package/{decorator → dist/decorator}/post.js.map +0 -0
- package/{filters → dist/filters}/AccessControl.js +0 -0
- package/{filters → dist/filters}/AccessControl.js.map +0 -0
- package/{filters → dist/filters}/AccessRule.js +0 -0
- package/{filters → dist/filters}/AccessRule.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js +0 -0
- package/{filters → dist/filters}/auth/AuthInterface.js.map +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js +0 -0
- package/{filters → dist/filters}/auth/AuthMethod.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBasicAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js +0 -0
- package/{filters → dist/filters}/auth/HttpHeaderAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/JwtHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js +0 -0
- package/{filters → dist/filters}/auth/KeyCloakHttpBearerAuth.js.map +0 -0
- package/{filters → dist/filters}/auth/index.js +0 -0
- package/{filters → dist/filters}/auth/index.js.map +0 -0
- package/{filters → dist/filters}/index.js +0 -0
- package/{filters → dist/filters}/index.js.map +0 -0
- package/{index.js → dist/index.js} +0 -3
- package/{index.js.map → dist/index.js.map} +1 -1
- package/dist/log/config/log4js.json +55 -0
- package/{model → dist/model}/RouteDefinition.js +0 -0
- package/{model → dist/model}/RouteDefinition.js.map +0 -0
- package/dist/package.json +59 -0
- package/{rbac → dist/rbac}/AuthAssignment.js +0 -0
- package/{rbac → dist/rbac}/AuthAssignment.js.map +0 -0
- package/{rbac → dist/rbac}/AuthItem.js +0 -0
- package/{rbac → dist/rbac}/AuthItem.js.map +0 -0
- package/{rbac → dist/rbac}/AuthItemChild.js +0 -0
- package/{rbac → dist/rbac}/AuthItemChild.js.map +0 -0
- package/{rbac → dist/rbac}/AuthManager.js +0 -0
- package/{rbac → dist/rbac}/AuthManager.js.map +0 -0
- package/{requiments → dist/requiments}/Glob.js +0 -0
- package/{requiments → dist/requiments}/Glob.js.map +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js +0 -0
- package/{requiments → dist/requiments}/ReflectUtil.js.map +0 -0
- package/{requiments → dist/requiments}/Utils.js +0 -0
- package/{requiments → dist/requiments}/Utils.js.map +0 -0
- package/{validators → dist/validators}/BooleanValidator.js +0 -0
- package/{validators → dist/validators}/BooleanValidator.js.map +0 -0
- package/{validators → dist/validators}/CompareValidator.js +0 -0
- package/{validators → dist/validators}/CompareValidator.js.map +0 -0
- package/{validators → dist/validators}/DateValidator.js +0 -0
- package/{validators → dist/validators}/DateValidator.js.map +0 -0
- package/{validators → dist/validators}/EmailValidator.js +0 -0
- package/{validators → dist/validators}/EmailValidator.js.map +0 -0
- package/{validators → dist/validators}/Validator.js +0 -0
- package/{validators → dist/validators}/Validator.js.map +0 -0
- package/{web → dist/web}/IdentityInterface.js +0 -0
- package/{web → dist/web}/IdentityInterface.js.map +0 -0
- package/{web → dist/web}/WebUser.js +0 -0
- package/{web → dist/web}/WebUser.js.map +0 -0
- package/filters/AccessControl.ts +77 -0
- package/filters/AccessRule.ts +182 -0
- package/filters/auth/AuthInterface.ts +34 -0
- package/filters/auth/AuthMethod.ts +88 -0
- package/filters/auth/HttpBasicAuth.ts +75 -0
- package/filters/auth/HttpBearerAuth.ts +31 -0
- package/filters/auth/HttpHeaderAuth.ts +53 -0
- package/filters/auth/JwtHttpBearerAuth.ts +80 -0
- package/filters/auth/KeyCloakHttpBearerAuth.ts +115 -0
- package/filters/auth/index.ts +4 -0
- package/filters/index.ts +2 -0
- package/index.ts +16 -0
- package/model/RouteDefinition.ts +18 -0
- package/package-lock.json +5259 -0
- package/package.json +1 -1
- package/rbac/AuthAssignment.ts +50 -0
- package/rbac/AuthItem.ts +57 -0
- package/rbac/AuthItemChild.ts +50 -0
- package/rbac/AuthManager.ts +398 -0
- package/requiments/Glob.ts +9 -0
- package/requiments/ReflectUtil.ts +26 -0
- package/requiments/Utils.ts +63 -0
- package/tsconfig.json +18 -0
- package/validators/BooleanValidator.ts +0 -0
- package/validators/CompareValidator.ts +0 -0
- package/validators/DateValidator.ts +0 -0
- package/validators/EmailValidator.ts +0 -0
- package/validators/Validator.ts +27 -0
- package/web/IdentityInterface.ts +68 -0
- package/web/WebUser.ts +187 -0
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
// @ts-ignore
|
|
9
|
+
import "reflect-metadata";
|
|
10
|
+
export const controller = (prefix: string = ''): ClassDecorator => {
|
|
11
|
+
return (target: any) => {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
Reflect.defineMetadata('prefix', prefix, target);
|
|
14
|
+
|
|
15
|
+
// Since routes are set by our methods this should almost never be true (except the controller has no methods)
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
if (! Reflect.hasMetadata('routes', target)) {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
Reflect.defineMetadata('routes', [], target);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
package/decorator/get.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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 "reflect-metadata";
|
|
9
|
+
import {RouteDefinition} from '../model/RouteDefinition';
|
|
10
|
+
|
|
11
|
+
export const get = (path: string): MethodDecorator => {
|
|
12
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return (target, propertyKey: string): void => {
|
|
15
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
16
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor) as Array<RouteDefinition>;
|
|
26
|
+
|
|
27
|
+
routes.push({
|
|
28
|
+
id:"",
|
|
29
|
+
requestMethod: 'get',
|
|
30
|
+
path,
|
|
31
|
+
methodName: propertyKey
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 "reflect-metadata";
|
|
9
|
+
import {RouteDefinition} from '../model/RouteDefinition';
|
|
10
|
+
|
|
11
|
+
export const post = (path: string): MethodDecorator => {
|
|
12
|
+
// `target` equals our class, `propertyKey` equals our decorated method name
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
return (target, propertyKey: string): void => {
|
|
15
|
+
// In case this is the first route to be registered the `routes` metadata is likely to be undefined at this point.
|
|
16
|
+
// To prevent any further validation simply set it to an empty array here.
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
if (!Reflect.hasMetadata('routes', target.constructor)) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
Reflect.defineMetadata('routes', [], target.constructor);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Get the routes stored so far, extend it by the new route and re-set the metadata.
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
const routes = Reflect.getMetadata('routes', target.constructor) as Array<RouteDefinition>;
|
|
26
|
+
|
|
27
|
+
routes.push({
|
|
28
|
+
id:"",
|
|
29
|
+
requestMethod: 'post',
|
|
30
|
+
path,
|
|
31
|
+
methodName: propertyKey
|
|
32
|
+
});
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
Reflect.defineMetadata('routes', routes, target.constructor);
|
|
35
|
+
};
|
|
36
|
+
};
|
|
File without changes
|
|
File without changes
|
package/{Chyz.js → dist/Chyz.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -23,9 +23,6 @@ var WebUser_1 = require("./web/WebUser");
|
|
|
23
23
|
Object.defineProperty(exports, "WebUser", { enumerable: true, get: function () { return WebUser_1.WebUser; } });
|
|
24
24
|
const BaseChyz_1 = __importDefault(require("./BaseChyz"));
|
|
25
25
|
exports.BaseChyz = BaseChyz_1.default;
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
26
|
const Chyz = new BaseChyz_1.default();
|
|
30
27
|
exports.default = Chyz;
|
|
31
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yCAAuB;AACvB,4CAA0B;AAC1B,iDAA+B;AAC/B,8CAA4B;AAC5B,qDAAmC;AAEnC,yCAAsC;AAA9B,kGAAA,OAAO,OAAA;AAEf,0DAAkC;AAC1B,mBADD,kBAAQ,CACC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yCAAuB;AACvB,4CAA0B;AAC1B,iDAA+B;AAC/B,8CAA4B;AAC5B,qDAAmC;AAEnC,yCAAsC;AAA9B,kGAAA,OAAO,OAAA;AAEf,0DAAkC;AAC1B,mBADD,kBAAQ,CACC;AAEhB,MAAM,IAAI,GAAG,IAAI,kBAAQ,EAAE,CAAC;AAC5B,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"appenders": {
|
|
3
|
+
"access": {
|
|
4
|
+
"type": "dateFile",
|
|
5
|
+
"filename": "log/access.log",
|
|
6
|
+
"pattern": "-yyyy-MM-dd",
|
|
7
|
+
"category": "http",
|
|
8
|
+
"layout": {
|
|
9
|
+
"type": "pattern",
|
|
10
|
+
"pattern": "[%d{yyyy-MM-ddThh.mm.ss.SSS}] [%p] %c [%l] [%f] - %m"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"app": {
|
|
14
|
+
"type": "file",
|
|
15
|
+
"filename": "log/app.log",
|
|
16
|
+
"maxLogSize": 10485760,
|
|
17
|
+
"numBackups": 3,
|
|
18
|
+
"layout": {
|
|
19
|
+
"type": "pattern",
|
|
20
|
+
"pattern": "[%d{yyyy-MM-ddThh.mm.ss.SSS}] [%p] %c [%l] [%f] - %m"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"errorFile": {
|
|
24
|
+
"type": "file",
|
|
25
|
+
"filename": "log/errors.log",
|
|
26
|
+
"layout": {
|
|
27
|
+
"type": "pattern",
|
|
28
|
+
"pattern": "[%d{yyyy-MM-ddThh.mm.ss.SSS}] [%p] %c [%l] [%f] - %m"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"errors": {
|
|
32
|
+
"type": "logLevelFilter",
|
|
33
|
+
"level": "ERROR",
|
|
34
|
+
"appender": "errorFile",
|
|
35
|
+
"layout": {
|
|
36
|
+
"type": "pattern",
|
|
37
|
+
"pattern": "[%d{yyyy-MM-ddThh.mm.ss.SSS}] [%p] %c [%l] [%f] - %m"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"console": {
|
|
41
|
+
"type": "stdout"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"categories": {
|
|
45
|
+
"default": {
|
|
46
|
+
"appenders": ["console","app" ,"errors" ],
|
|
47
|
+
"level": "ALL",
|
|
48
|
+
"enableCallStack": true
|
|
49
|
+
},
|
|
50
|
+
"http": {
|
|
51
|
+
"level": "INFO",
|
|
52
|
+
"appenders": [ "access" ]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chyz",
|
|
3
|
+
"version": "1.1.1-rc.2",
|
|
4
|
+
"description": "Nodejs Micro service Framework",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "nodemon -t --trace-warnings index.ts",
|
|
7
|
+
"debug": "ts-node index.ts",
|
|
8
|
+
"build": "rmdir /S /Q .\\dist && npx tsc && xcopy .\\log .\\dist\\log /e /i /h /Y && copy .\\package.json .\\dist\\package.json",
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"postversion": "git push && git push --tags"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/cihan53/Chy-Nodejs-Framework.git"
|
|
15
|
+
},
|
|
16
|
+
"author": "Cihan Ozturk",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/cihan53/Chy-Nodejs-Framework/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/cihan53/Chy-Nodejs-Framework#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"axios": "^0.23.0",
|
|
24
|
+
"babel-plugin-transform-decorators-legacy": "^1.3.5",
|
|
25
|
+
"body-parser": "^1.19.0",
|
|
26
|
+
"dotenv-flow": "^3.2.0",
|
|
27
|
+
"express": "^4.17.1",
|
|
28
|
+
"express-session": "^1.17.2",
|
|
29
|
+
"glob": "^7.1.7",
|
|
30
|
+
"ip": "^1.1.5",
|
|
31
|
+
"jsonwebtoken": "^8.5.1",
|
|
32
|
+
"lodash": "^4.17.21",
|
|
33
|
+
"log4js": "^6.3.0",
|
|
34
|
+
"method-override": "^3.0.0",
|
|
35
|
+
"passport": "^0.4.1",
|
|
36
|
+
"pg": "^8.7.1",
|
|
37
|
+
"pg-hstore": "^2.3.4",
|
|
38
|
+
"reflect-metadata": "^0.1.13",
|
|
39
|
+
"sequelize": "^6.6.5",
|
|
40
|
+
"sequelize-transparent-cache": "^2.3.0",
|
|
41
|
+
"validate.js": "^0.13.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/express": "^4.17.13",
|
|
45
|
+
"@types/node": "^16.6.1",
|
|
46
|
+
"@types/validator": "^13.6.3",
|
|
47
|
+
"nodemon": "^2.0.12",
|
|
48
|
+
"ts-node": "^10.2.0",
|
|
49
|
+
"typescript": "^4.3.5"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"Framework",
|
|
53
|
+
"RespAPI",
|
|
54
|
+
"microservice",
|
|
55
|
+
"micro service",
|
|
56
|
+
"easy configuration",
|
|
57
|
+
"Rbac support"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,77 @@
|
|
|
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 BaseChyz from "../BaseChyz";
|
|
8
|
+
import {ForbiddenHttpException} from "../base/ForbiddenHttpException";
|
|
9
|
+
import {ActionFilter} from "../base/ActionFilter";
|
|
10
|
+
import {AccessRule} from "./AccessRule";
|
|
11
|
+
import {WebUser} from "../web/WebUser";
|
|
12
|
+
import Utils from "../requiments/Utils";
|
|
13
|
+
import {NextFunction, Request, Response} from "express";
|
|
14
|
+
|
|
15
|
+
var _ = require('lodash');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export class AccessControl extends ActionFilter {
|
|
19
|
+
|
|
20
|
+
public user: any = null;
|
|
21
|
+
public rules: any;
|
|
22
|
+
public denyCallback: any = null;
|
|
23
|
+
|
|
24
|
+
public init() {
|
|
25
|
+
super.init()
|
|
26
|
+
|
|
27
|
+
if (this.user == undefined) {
|
|
28
|
+
this.user = Utils.cloneDeep(BaseChyz.getComponent("user")) ?? new WebUser();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.rules.forEach((rule: any, index: number) => {
|
|
32
|
+
if (rule === Object(rule)) {
|
|
33
|
+
this.rules[index] = Utils.createObject(new AccessRule(), rule);
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
public async beforeAction(action: any, request: Request) {
|
|
40
|
+
let allow;
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
let user = request.user ?? this.user;
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
user.identity = request.identity ?? null;
|
|
45
|
+
|
|
46
|
+
for (const rulesKey in this.rules) {
|
|
47
|
+
|
|
48
|
+
let rule = this.rules[rulesKey];
|
|
49
|
+
if ((allow = await rule.allows(action, user, request))) {
|
|
50
|
+
return true;
|
|
51
|
+
} else if (allow === false) {
|
|
52
|
+
if (this.denyCallback != null) {
|
|
53
|
+
rule.denyCallback.apply(rule, action);
|
|
54
|
+
} else {
|
|
55
|
+
this.denyAccess(user);
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
if (this.denyCallback != null) {
|
|
63
|
+
this.denyCallback.apply(null, action);
|
|
64
|
+
} else {
|
|
65
|
+
this.denyAccess(user);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public denyAccess(user: WebUser) {
|
|
72
|
+
if (user != undefined && user.getIsGuest()) {
|
|
73
|
+
user.loginRequired();
|
|
74
|
+
} else throw new ForbiddenHttpException(BaseChyz.t('You are not allowed to perform this action.'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|