chyz 1.0.12-rc.14
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 +316 -0
- package/Chyz.ts +11 -0
- package/Examples/Controllers/ApiController.ts +121 -0
- package/Examples/Controllers/PublicController.ts +44 -0
- package/Examples/Controllers/SiteController.ts +127 -0
- package/Examples/Models/Customer.ts +113 -0
- package/Examples/Models/Order.ts +48 -0
- package/Examples/Models/OrderItem.ts +26 -0
- package/Examples/Models/User.ts +80 -0
- package/Examples/index.ts +38 -0
- package/Examples/log/access.log +0 -0
- package/Examples/log/app.log +3264 -0
- package/Examples/log/errors.log +534 -0
- package/Examples/package.json +45 -0
- package/Examples/tsconfig.json +20 -0
- package/Examples/yarn.lock +2202 -0
- package/README.md +218 -0
- package/base/ActionFilter.ts +71 -0
- package/base/BaseError.ts +26 -0
- package/base/BaseObject.ts +19 -0
- package/base/Behavior.ts +6 -0
- package/base/Component.ts +66 -0
- package/base/Configurable.ts +10 -0
- package/base/Controller.ts +84 -0
- package/base/DataErrorDbException.ts +16 -0
- package/base/DbConnection.ts +51 -0
- package/base/ForbiddenHttpException.ts +15 -0
- package/base/InvalidConfigException.ts +16 -0
- package/base/Model.ts +254 -0
- package/base/NotFoundHttpException.ts +14 -0
- package/base/RestClient.ts +27 -0
- package/base/UnauthorizedHttpException.ts +16 -0
- package/base/ValidationHttpException.ts +14 -0
- package/base/db/Exception.ts +14 -0
- package/base/index.ts +16 -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/dist/BaseChyz.js +257 -0
- package/dist/BaseChyz.js.map +1 -0
- package/dist/Chyz.js +15 -0
- package/dist/Chyz.js.map +1 -0
- package/dist/base/ActionFilter.js +75 -0
- package/dist/base/ActionFilter.js.map +1 -0
- package/dist/base/BaseError.js +26 -0
- package/dist/base/BaseError.js.map +1 -0
- package/dist/base/BaseObject.js +20 -0
- package/dist/base/BaseObject.js.map +1 -0
- package/dist/base/Behavior.js +8 -0
- package/dist/base/Behavior.js.map +1 -0
- package/dist/base/Component.js +61 -0
- package/dist/base/Component.js.map +1 -0
- package/dist/base/Configurable.js +9 -0
- package/dist/base/Configurable.js.map +1 -0
- package/dist/base/Controller.js +75 -0
- package/dist/base/Controller.js.map +1 -0
- package/dist/base/DataErrorDbException.js +18 -0
- package/dist/base/DataErrorDbException.js.map +1 -0
- package/dist/base/DbConnection.js +53 -0
- package/dist/base/DbConnection.js.map +1 -0
- package/dist/base/ForbiddenHttpException.js +17 -0
- package/dist/base/ForbiddenHttpException.js.map +1 -0
- package/dist/base/InvalidConfigException.js +18 -0
- package/dist/base/InvalidConfigException.js.map +1 -0
- package/dist/base/Model.js +243 -0
- package/dist/base/Model.js.map +1 -0
- package/dist/base/NotFoundHttpException.js +18 -0
- package/dist/base/NotFoundHttpException.js.map +1 -0
- package/dist/base/RestClient.js +26 -0
- package/dist/base/RestClient.js.map +1 -0
- package/dist/base/UnauthorizedHttpException.js +18 -0
- package/dist/base/UnauthorizedHttpException.js.map +1 -0
- package/dist/base/ValidationHttpException.js +18 -0
- package/dist/base/ValidationHttpException.js.map +1 -0
- package/dist/base/db/Exception.js +16 -0
- package/dist/base/db/Exception.js.map +1 -0
- package/dist/base/index.js +29 -0
- package/dist/base/index.js.map +1 -0
- package/dist/decorator/Middleware.js +12 -0
- package/dist/decorator/Middleware.js.map +1 -0
- package/dist/decorator/controller.js +25 -0
- package/dist/decorator/controller.js.map +1 -0
- package/dist/decorator/enums/ControllerDecoratorParams.js +10 -0
- package/dist/decorator/enums/ControllerDecoratorParams.js.map +1 -0
- package/dist/decorator/get.js +37 -0
- package/dist/decorator/get.js.map +1 -0
- package/dist/decorator/index.js +16 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/post.js +37 -0
- package/dist/decorator/post.js.map +1 -0
- package/dist/filters/AccessControl.js +76 -0
- package/dist/filters/AccessControl.js.map +1 -0
- package/dist/filters/AccessRule.js +79 -0
- package/dist/filters/AccessRule.js.map +1 -0
- package/dist/filters/auth/AuthInterface.js +3 -0
- package/dist/filters/auth/AuthInterface.js.map +1 -0
- package/dist/filters/auth/AuthMethod.js +71 -0
- package/dist/filters/auth/AuthMethod.js.map +1 -0
- package/dist/filters/auth/HttpBasicAuth.js +8 -0
- package/dist/filters/auth/HttpBasicAuth.js.map +1 -0
- package/dist/filters/auth/HttpBearerAuth.js +33 -0
- package/dist/filters/auth/HttpBearerAuth.js.map +1 -0
- package/dist/filters/auth/HttpHeaderAuth.js +61 -0
- package/dist/filters/auth/HttpHeaderAuth.js.map +1 -0
- package/dist/filters/auth/JwtHttpBearerAuth.js +82 -0
- package/dist/filters/auth/JwtHttpBearerAuth.js.map +1 -0
- package/dist/filters/auth/index.js +16 -0
- package/dist/filters/auth/index.js.map +1 -0
- package/dist/filters/index.js +15 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/log/config/log4js.json +55 -0
- package/dist/model/RouteDefinition.js +9 -0
- package/dist/model/RouteDefinition.js.map +1 -0
- package/dist/requiments/Glob.js +11 -0
- package/dist/requiments/Glob.js.map +1 -0
- package/dist/requiments/ReflectUtil.js +25 -0
- package/dist/requiments/ReflectUtil.js.map +1 -0
- package/dist/requiments/Utils.js +40 -0
- package/dist/requiments/Utils.js.map +1 -0
- package/dist/validators/BooleanValidator.js +2 -0
- package/dist/validators/BooleanValidator.js.map +1 -0
- package/dist/validators/CompareValidator.js +2 -0
- package/dist/validators/CompareValidator.js.map +1 -0
- package/dist/validators/DateValidator.js +2 -0
- package/dist/validators/DateValidator.js.map +1 -0
- package/dist/validators/EmailValidator.js +2 -0
- package/dist/validators/EmailValidator.js.map +1 -0
- package/dist/validators/Validator.js +28 -0
- package/dist/validators/Validator.js.map +1 -0
- package/dist/web/IdentityInterface.js +9 -0
- package/dist/web/IdentityInterface.js.map +1 -0
- package/dist/web/User.js +83 -0
- package/dist/web/User.js.map +1 -0
- package/filters/AccessControl.ts +64 -0
- package/filters/AccessRule.ts +137 -0
- package/filters/auth/AuthInterface.ts +34 -0
- package/filters/auth/AuthMethod.ts +88 -0
- package/filters/auth/HttpBasicAuth.ts +7 -0
- package/filters/auth/HttpBearerAuth.ts +31 -0
- package/filters/auth/HttpHeaderAuth.ts +53 -0
- package/filters/auth/JwtHttpBearerAuth.ts +81 -0
- package/filters/auth/index.ts +3 -0
- package/filters/index.ts +2 -0
- package/index.ts +14 -0
- package/log/config/log4js.json +55 -0
- package/model/RouteDefinition.ts +18 -0
- package/package.json +52 -0
- package/requiments/Glob.ts +9 -0
- package/requiments/ReflectUtil.ts +26 -0
- package/requiments/Utils.ts +57 -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 +62 -0
- package/web/User.ts +96 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import {DataTypes, Model} from "../../base";
|
|
3
|
+
|
|
4
|
+
export class Customer extends Model {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
|
|
7
|
+
public tableName() {
|
|
8
|
+
return 'customer';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public attributes() {
|
|
12
|
+
return {
|
|
13
|
+
name: {
|
|
14
|
+
type: DataTypes.STRING,
|
|
15
|
+
allowNull: false,
|
|
16
|
+
validate: {
|
|
17
|
+
notEmpty: true,
|
|
18
|
+
is: ["^[a-z0-9A-Z]+$",'i'],
|
|
19
|
+
len: [4, 255],
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
firstname: {
|
|
23
|
+
type: DataTypes.STRING,
|
|
24
|
+
validate: {
|
|
25
|
+
is: ["^[a-z0-9A-Z]+$",'i'],
|
|
26
|
+
len: [4, 255],
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
lastname: {
|
|
30
|
+
type: DataTypes.STRING,
|
|
31
|
+
validate: {
|
|
32
|
+
is: ["^[a-z0-9A-Z]+$",'i'],
|
|
33
|
+
len: [4, 255],
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
companyName: {
|
|
37
|
+
type: DataTypes.STRING,
|
|
38
|
+
allowNull: true,
|
|
39
|
+
validate: {
|
|
40
|
+
is: /^[0-9A-Za-z =().:;+-şŞçÇöÖğĞıİüÜ]+$/i,
|
|
41
|
+
len: [4, 255],
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
email: {
|
|
45
|
+
type: DataTypes.STRING,
|
|
46
|
+
validate: {
|
|
47
|
+
isEmail: true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
gsm_phone: {
|
|
51
|
+
type: DataTypes.STRING,
|
|
52
|
+
validate: {
|
|
53
|
+
is: ["^[0-9 +]+$",'i'],
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
country: {
|
|
57
|
+
type: DataTypes.STRING,
|
|
58
|
+
validate: {
|
|
59
|
+
isAlpha: true,
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
address: {
|
|
63
|
+
type: DataTypes.STRING,
|
|
64
|
+
validate: {
|
|
65
|
+
is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$","i"],
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
taxoffice: {
|
|
69
|
+
type: DataTypes.STRING,
|
|
70
|
+
validate: {
|
|
71
|
+
is: ["^[\\w'\\-,.[0-9_\\/\\\\+=\"()<>;:\\[\\] şŞçÇöÖğĞıİüÜ ]{2,}$","i"],
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
taxnumber: {
|
|
75
|
+
unique: true,
|
|
76
|
+
type: DataTypes.STRING,
|
|
77
|
+
validate: {
|
|
78
|
+
is:["^[0-9]+$",'i'],
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
username: {
|
|
82
|
+
unique: true,
|
|
83
|
+
type: DataTypes.STRING,
|
|
84
|
+
validate: {
|
|
85
|
+
isEmail: true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
password: {
|
|
89
|
+
type: DataTypes.STRING,
|
|
90
|
+
validate: {
|
|
91
|
+
is: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!%*?\.#&])[A-Za-z\d$@$!%*\.?&]{8,12}/
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"2fa": {
|
|
95
|
+
type: DataTypes.BOOLEAN,
|
|
96
|
+
validate: {
|
|
97
|
+
isBoolean: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
status: {
|
|
101
|
+
type: DataTypes.BOOLEAN,
|
|
102
|
+
validate: {
|
|
103
|
+
isBoolean: true
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {DataTypes, Model} from "../../base";
|
|
2
|
+
|
|
3
|
+
export class Order extends Model {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
|
|
6
|
+
public tableName() {
|
|
7
|
+
return 'order';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public attributes() {
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
customer_id:{
|
|
14
|
+
allowNull:false,
|
|
15
|
+
type:DataTypes.INTEGER,
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
crm_order_id:{
|
|
19
|
+
allowNull:false,
|
|
20
|
+
type:DataTypes.INTEGER,
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
total:{
|
|
24
|
+
allowNull:false,
|
|
25
|
+
type:DataTypes.FLOAT,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
created_date:{
|
|
29
|
+
allowNull:false,
|
|
30
|
+
type:DataTypes.DATE,
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
defaultValue: Model.NOW
|
|
33
|
+
},
|
|
34
|
+
status: {
|
|
35
|
+
type: DataTypes.BOOLEAN,
|
|
36
|
+
allowNull:false,
|
|
37
|
+
validate: {
|
|
38
|
+
isBoolean: true
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {DataTypes, Model} from "../../Chy-Nodejs-Framework/dist/base";
|
|
2
|
+
|
|
3
|
+
export class OrderItem extends Model {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
|
|
6
|
+
public tableName() {
|
|
7
|
+
return 'order_items';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public attributes() {
|
|
11
|
+
return {
|
|
12
|
+
|
|
13
|
+
status: {
|
|
14
|
+
type: DataTypes.BOOLEAN,
|
|
15
|
+
validate: {
|
|
16
|
+
isBoolean: true
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
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 {IdentityInterface} from "../../web/IdentityInterface";
|
|
9
|
+
import {DataTypes, Model} from "../../base";
|
|
10
|
+
import BaseChyz from "../../BaseChyz";
|
|
11
|
+
const JsonWebToken = require("jsonwebtoken");
|
|
12
|
+
export class User extends Model implements IdentityInterface {
|
|
13
|
+
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
|
|
16
|
+
public tableName() {
|
|
17
|
+
return 'users';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
findIdentity(id: number) {
|
|
21
|
+
throw new Error("Method not implemented.");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getId(): number {
|
|
25
|
+
throw new Error("Method not implemented.");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getAuthKey(): string {
|
|
29
|
+
throw new Error("Method not implemented.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
validateAuthKey(authKey: string): boolean {
|
|
33
|
+
throw new Error("Method not implemented.");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public attributes() {
|
|
37
|
+
return {
|
|
38
|
+
// Model attributes are defined here
|
|
39
|
+
username: {
|
|
40
|
+
type: DataTypes.STRING,
|
|
41
|
+
allowNull: false
|
|
42
|
+
},
|
|
43
|
+
password: {
|
|
44
|
+
type: DataTypes.STRING,
|
|
45
|
+
allowNull: false
|
|
46
|
+
},
|
|
47
|
+
user_role: {
|
|
48
|
+
type: DataTypes.STRING,
|
|
49
|
+
allowNull: false
|
|
50
|
+
},
|
|
51
|
+
salt_text: {
|
|
52
|
+
type: DataTypes.STRING
|
|
53
|
+
// allowNull defaults to true
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async findIdentityByAccessToken(token, type) {
|
|
59
|
+
let decoded = JsonWebToken.decode(token, {complete: true})
|
|
60
|
+
let identity = await this.findOne({where: {id: parseInt(decoded.payload.user)}});
|
|
61
|
+
if (identity) {
|
|
62
|
+
BaseChyz.debug("Find Identity By AccessToken: User Found", decoded.payload)
|
|
63
|
+
try {
|
|
64
|
+
JsonWebToken.verify(token, identity.salt_text);
|
|
65
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Success")
|
|
66
|
+
return identity;
|
|
67
|
+
} catch (err) {
|
|
68
|
+
if (err.name == "TokenExpiredError")
|
|
69
|
+
BaseChyz.debug("Find Identity By AccessToken: Token Expired")
|
|
70
|
+
else
|
|
71
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
BaseChyz.debug("Find Identity By AccessToken: User Verify Failed")
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
require('dotenv-flow').config();
|
|
9
|
+
import Chyz from "../Chyz";
|
|
10
|
+
import {User} from "../web/User";
|
|
11
|
+
import {User as Identity } from "./Models/User";
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
import {DbConnection} from "../base/DbConnection";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
let config = {
|
|
17
|
+
port: 3000,
|
|
18
|
+
controllerpath:"C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
|
|
19
|
+
components: {
|
|
20
|
+
db:{
|
|
21
|
+
class:DbConnection,
|
|
22
|
+
database: process.env.DBDATABASE,
|
|
23
|
+
username:process.env.DBUSER,
|
|
24
|
+
password:process.env.DBPASS,
|
|
25
|
+
options:{
|
|
26
|
+
host: process.env.DBHOST,
|
|
27
|
+
dialect: 'postgres', /* one of 'mysql' | 'mariadb' | 'postgres' | 'mssql' */
|
|
28
|
+
// disable logging; default: console.log
|
|
29
|
+
logging: false
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
user: {
|
|
33
|
+
'class': User,
|
|
34
|
+
'identityClass':Identity
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
Chyz.app(config).Start();
|
|
File without changes
|