@duvdu-v1/duvdu 1.1.89 → 1.1.90
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.
|
@@ -6,18 +6,18 @@ const checkRequiredFields = (options) => ((req, res, next) => {
|
|
|
6
6
|
var _a;
|
|
7
7
|
if (options.single) {
|
|
8
8
|
if (!req.file || req.file.fieldname !== options.single)
|
|
9
|
-
return next(new bad_request_error_1.BadRequestError(`${options.single} is required
|
|
9
|
+
return next(new bad_request_error_1.BadRequestError({ en: `${options.single} is required`, ar: `${options.single} مطلوب` }, req.lang));
|
|
10
10
|
}
|
|
11
11
|
else if (options.array) {
|
|
12
12
|
if (!req.files || !Array.isArray(req.files) || req.files[0].fieldname !== options.array)
|
|
13
|
-
return next(new bad_request_error_1.BadRequestError(`${options.array} is required
|
|
13
|
+
return next(new bad_request_error_1.BadRequestError({ en: `${options.array} is required`, ar: `${options.array} مطلوب` }, req.lang));
|
|
14
14
|
}
|
|
15
15
|
else if (options.fields) {
|
|
16
16
|
if (!req.files)
|
|
17
|
-
return next(new bad_request_error_1.BadRequestError(`${options.fields.join(' ')} is required
|
|
17
|
+
return next(new bad_request_error_1.BadRequestError({ en: `${options.fields.join(' ')} is required`, ar: `${options.fields.join(' ')} مطلوب` }, req.lang));
|
|
18
18
|
for (const field of options.fields) {
|
|
19
19
|
if (!((_a = req.files) === null || _a === void 0 ? void 0 : _a[field]))
|
|
20
|
-
return next(new bad_request_error_1.BadRequestError(`${field} is required
|
|
20
|
+
return next(new bad_request_error_1.BadRequestError({ en: `${field} is required`, ar: `${field} مطلوب` }));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
next();
|
|
@@ -16,7 +16,7 @@ const isauthorized = (permission) => ((req, res, next) => __awaiter(void 0, void
|
|
|
16
16
|
if (req.loggedUser.role.key === systemRoles_1.SystemRoles.admin)
|
|
17
17
|
return next();
|
|
18
18
|
if (!req.loggedUser.role.permissions.includes(permission))
|
|
19
|
-
return next(new unauthorized_error_1.UnauthorizedError());
|
|
19
|
+
return next(new unauthorized_error_1.UnauthorizedError(undefined, req.lang));
|
|
20
20
|
next();
|
|
21
21
|
}));
|
|
22
22
|
exports.isauthorized = isauthorized;
|
|
@@ -20,7 +20,10 @@ const optionalAuthenticated = (req, res, next) => __awaiter(void 0, void 0, void
|
|
|
20
20
|
payload = (0, jsonwebtoken_1.verify)(req.session.access, process.env.JWT_KEY);
|
|
21
21
|
req.loggedUser = payload;
|
|
22
22
|
if (req.loggedUser.isBlocked.value)
|
|
23
|
-
return next(new unauthorized_error_1.UnauthorizedError(
|
|
23
|
+
return next(new unauthorized_error_1.UnauthorizedError({
|
|
24
|
+
en: `Forbidden: User is blocked ${req.loggedUser.isBlocked.reason}`,
|
|
25
|
+
ar: ` ممنوع: المستخدم محظور ${req.loggedUser.isBlocked.reason}`,
|
|
26
|
+
}, req.lang));
|
|
24
27
|
}
|
|
25
28
|
catch (error) {
|
|
26
29
|
return next();
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@duvdu-v1/duvdu",
|
|
3
|
-
"version": "1.1.
|
|
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
|
-
"fix:build": "mv ./build/common/src/* ./build && rm -rf ./build/auth ./build/common",
|
|
13
|
-
"pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
|
|
14
|
-
"lint": "eslint .",
|
|
15
|
-
"lint:fix": "eslint --fix .",
|
|
16
|
-
"format": "prettier --write ."
|
|
17
|
-
},
|
|
18
|
-
"keywords": [],
|
|
19
|
-
"author": "motemed khaled",
|
|
20
|
-
"license": "ISC",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"@duvdu-v1/duvdu": "^1.1.4",
|
|
23
|
-
"@types/express": "^4.17.21",
|
|
24
|
-
"@types/express-session": "^1.18.0",
|
|
25
|
-
"@types/jsonwebtoken": "^9.0.5",
|
|
26
|
-
"@types/multer": "^1.4.11",
|
|
27
|
-
"@types/node": "^20.11.0",
|
|
28
|
-
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
29
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
30
|
-
"aws-sdk": "^2.1595.0",
|
|
31
|
-
"connect-redis": "^7.1.1",
|
|
32
|
-
"express": "^4.18.2",
|
|
33
|
-
"express-async-errors": "^3.1.1",
|
|
34
|
-
"express-session": "^1.18.0",
|
|
35
|
-
"express-validator": "^7.0.1",
|
|
36
|
-
"jsonwebtoken": "^9.0.2",
|
|
37
|
-
"mongoose": "^8.0.4",
|
|
38
|
-
"multer": "^1.4.5-lts.1",
|
|
39
|
-
"node-nats-streaming": "^0.3.2",
|
|
40
|
-
"redis": "^4.6.13",
|
|
41
|
-
"rimraf": "^5.0.5",
|
|
42
|
-
"typescript": "^5.3.3",
|
|
43
|
-
"uuid": "^9.0.1"
|
|
44
|
-
},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@types/uuid": "^9.0.8",
|
|
47
|
-
"del-cli": "^5.1.0",
|
|
48
|
-
"eslint": "^8.56.0",
|
|
49
|
-
"eslint-config-prettier": "^9.1.0",
|
|
50
|
-
"eslint-plugin-import": "^2.29.1",
|
|
51
|
-
"eslint-plugin-prettier": "^5.1.3",
|
|
52
|
-
"prettier": "^3.2.4"
|
|
53
|
-
},
|
|
54
|
-
"description": ""
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@duvdu-v1/duvdu",
|
|
3
|
+
"version": "1.1.90",
|
|
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
|
+
"fix:build": "mv ./build/common/src/* ./build && rm -rf ./build/auth ./build/common",
|
|
13
|
+
"pub": "git add . && git commit -m \"updates\" && npm version patch && npm run build && npm publish",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"lint:fix": "eslint --fix .",
|
|
16
|
+
"format": "prettier --write ."
|
|
17
|
+
},
|
|
18
|
+
"keywords": [],
|
|
19
|
+
"author": "motemed khaled",
|
|
20
|
+
"license": "ISC",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@duvdu-v1/duvdu": "^1.1.4",
|
|
23
|
+
"@types/express": "^4.17.21",
|
|
24
|
+
"@types/express-session": "^1.18.0",
|
|
25
|
+
"@types/jsonwebtoken": "^9.0.5",
|
|
26
|
+
"@types/multer": "^1.4.11",
|
|
27
|
+
"@types/node": "^20.11.0",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
29
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
30
|
+
"aws-sdk": "^2.1595.0",
|
|
31
|
+
"connect-redis": "^7.1.1",
|
|
32
|
+
"express": "^4.18.2",
|
|
33
|
+
"express-async-errors": "^3.1.1",
|
|
34
|
+
"express-session": "^1.18.0",
|
|
35
|
+
"express-validator": "^7.0.1",
|
|
36
|
+
"jsonwebtoken": "^9.0.2",
|
|
37
|
+
"mongoose": "^8.0.4",
|
|
38
|
+
"multer": "^1.4.5-lts.1",
|
|
39
|
+
"node-nats-streaming": "^0.3.2",
|
|
40
|
+
"redis": "^4.6.13",
|
|
41
|
+
"rimraf": "^5.0.5",
|
|
42
|
+
"typescript": "^5.3.3",
|
|
43
|
+
"uuid": "^9.0.1"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/uuid": "^9.0.8",
|
|
47
|
+
"del-cli": "^5.1.0",
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"eslint-config-prettier": "^9.1.0",
|
|
50
|
+
"eslint-plugin-import": "^2.29.1",
|
|
51
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
52
|
+
"prettier": "^3.2.4"
|
|
53
|
+
},
|
|
54
|
+
"description": ""
|
|
55
|
+
}
|