@duvdu-v1/duvdu 1.0.23 → 1.0.25
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/build/errors/data-base-connections.d.ts +0 -1
- package/build/errors/data-base-connections.js +1 -2
- package/build/errors/notfound-error.js +1 -1
- package/build/errors/unauthenticated-error.js +1 -1
- package/build/errors/unauthorized-error.js +1 -1
- package/build/middlewares/auth.middleware.js +3 -0
- package/package.json +46 -46
|
@@ -6,13 +6,12 @@ class DatabaseConnectionError extends custom_error_1.CustomError {
|
|
|
6
6
|
constructor(message) {
|
|
7
7
|
super(message || 'Error connecting to database');
|
|
8
8
|
this.statusCode = 500;
|
|
9
|
-
this.reason = 'Error connecting to database';
|
|
10
9
|
Object.setPrototypeOf(this, DatabaseConnectionError.prototype);
|
|
11
10
|
}
|
|
12
11
|
serializeError() {
|
|
13
12
|
return [
|
|
14
13
|
{
|
|
15
|
-
message: this.
|
|
14
|
+
message: this.message || 'Error connecting to database',
|
|
16
15
|
},
|
|
17
16
|
];
|
|
18
17
|
}
|
|
@@ -9,7 +9,7 @@ class NotFound extends custom_error_1.CustomError {
|
|
|
9
9
|
Object.setPrototypeOf(this, NotFound.prototype);
|
|
10
10
|
}
|
|
11
11
|
serializeError() {
|
|
12
|
-
return [{ message: 'not found error' }];
|
|
12
|
+
return [{ message: this.message || 'not found error' }];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.NotFound = NotFound;
|
|
@@ -9,7 +9,7 @@ class UnauthenticatedError extends custom_error_1.CustomError {
|
|
|
9
9
|
Object.setPrototypeOf(this, UnauthenticatedError.prototype);
|
|
10
10
|
}
|
|
11
11
|
serializeError() {
|
|
12
|
-
return [{ message: 'un-authenticated error' }];
|
|
12
|
+
return [{ message: this.message || 'un-authenticated error' }];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.UnauthenticatedError = UnauthenticatedError;
|
|
@@ -9,7 +9,7 @@ class UnauthorizedError extends custom_error_1.CustomError {
|
|
|
9
9
|
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
10
10
|
}
|
|
11
11
|
serializeError() {
|
|
12
|
-
return [{ message: 'un-unauthorized error' }];
|
|
12
|
+
return [{ message: this.message || 'un-unauthorized error' }];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.UnauthorizedError = UnauthorizedError;
|
|
@@ -27,6 +27,9 @@ const auth = (modelName) => ((req, res, next) => __awaiter(void 0, void 0, void
|
|
|
27
27
|
if (!user) {
|
|
28
28
|
throw new unauthenticated_error_1.UnauthenticatedError();
|
|
29
29
|
}
|
|
30
|
+
if (!user.isVerified) {
|
|
31
|
+
throw new unauthenticated_error_1.UnauthenticatedError('pleas verify your self first');
|
|
32
|
+
}
|
|
30
33
|
if (user.isBlocked) {
|
|
31
34
|
throw new generic_error_1.GenericError('the users access is denied due to their blocked status.');
|
|
32
35
|
}
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@duvdu-v1/duvdu",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "./build/index.js",
|
|
5
|
-
"types": "./build/index.d.ts",
|
|
6
|
-
"files": [
|
|
7
|
-
"build/**/*"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"clean": "rimraf ./build",
|
|
11
|
-
"build": "npm run clean && tsc",
|
|
12
|
-
"pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
|
|
13
|
-
"lint": "eslint .",
|
|
14
|
-
"lint:fix": "eslint --fix .",
|
|
15
|
-
"format": "prettier --write ."
|
|
16
|
-
},
|
|
17
|
-
"keywords": [],
|
|
18
|
-
"author": "motemed khaled",
|
|
19
|
-
"license": "ISC",
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@types/express": "^4.17.21",
|
|
22
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
23
|
-
"@types/multer": "^1.4.11",
|
|
24
|
-
"@types/node": "^20.11.0",
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
26
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
27
|
-
"express": "^4.18.2",
|
|
28
|
-
"express-async-errors": "^3.1.1",
|
|
29
|
-
"express-validator": "^7.0.1",
|
|
30
|
-
"jsonwebtoken": "^9.0.2",
|
|
31
|
-
"mongoose": "^8.0.4",
|
|
32
|
-
"multer": "^1.4.5-lts.1",
|
|
33
|
-
"node-nats-streaming": "^0.3.2",
|
|
34
|
-
"rimraf": "^5.0.5",
|
|
35
|
-
"typescript": "^5.3.3"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"del-cli": "^5.1.0",
|
|
39
|
-
"eslint": "^8.56.0",
|
|
40
|
-
"eslint-config-prettier": "^9.1.0",
|
|
41
|
-
"eslint-plugin-import": "^2.29.1",
|
|
42
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
43
|
-
"prettier": "^3.2.4"
|
|
44
|
-
},
|
|
45
|
-
"description": ""
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@duvdu-v1/duvdu",
|
|
3
|
+
"version": "1.0.25",
|
|
4
|
+
"main": "./build/index.js",
|
|
5
|
+
"types": "./build/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"build/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"clean": "rimraf ./build",
|
|
11
|
+
"build": "npm run clean && tsc",
|
|
12
|
+
"pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
|
|
13
|
+
"lint": "eslint .",
|
|
14
|
+
"lint:fix": "eslint --fix .",
|
|
15
|
+
"format": "prettier --write ."
|
|
16
|
+
},
|
|
17
|
+
"keywords": [],
|
|
18
|
+
"author": "motemed khaled",
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@types/express": "^4.17.21",
|
|
22
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
23
|
+
"@types/multer": "^1.4.11",
|
|
24
|
+
"@types/node": "^20.11.0",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
26
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
27
|
+
"express": "^4.18.2",
|
|
28
|
+
"express-async-errors": "^3.1.1",
|
|
29
|
+
"express-validator": "^7.0.1",
|
|
30
|
+
"jsonwebtoken": "^9.0.2",
|
|
31
|
+
"mongoose": "^8.0.4",
|
|
32
|
+
"multer": "^1.4.5-lts.1",
|
|
33
|
+
"node-nats-streaming": "^0.3.2",
|
|
34
|
+
"rimraf": "^5.0.5",
|
|
35
|
+
"typescript": "^5.3.3"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"del-cli": "^5.1.0",
|
|
39
|
+
"eslint": "^8.56.0",
|
|
40
|
+
"eslint-config-prettier": "^9.1.0",
|
|
41
|
+
"eslint-plugin-import": "^2.29.1",
|
|
42
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
43
|
+
"prettier": "^3.2.4"
|
|
44
|
+
},
|
|
45
|
+
"description": ""
|
|
46
|
+
}
|