@duvdu-v1/duvdu 1.0.25 → 1.0.27
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.
|
@@ -9,7 +9,7 @@ class BadRequestError extends custom_error_1.CustomError {
|
|
|
9
9
|
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
10
10
|
}
|
|
11
11
|
serializeError() {
|
|
12
|
-
return [{ message: this.message }];
|
|
12
|
+
return [{ message: this.message || 'bad-request error' }];
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
exports.BadRequestError = BadRequestError;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -33,3 +33,4 @@ __exportStar(require("./middlewares/database-connection"), exports);
|
|
|
33
33
|
__exportStar(require("./types/JwtPayload"), exports);
|
|
34
34
|
__exportStar(require("./middlewares/global-validator.middleware"), exports);
|
|
35
35
|
__exportStar(require("./middlewares/auth.middleware"), exports);
|
|
36
|
+
__exportStar(require("./middlewares/global-upload.middleware"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.globalUploadMiddleware = void 0;
|
|
7
|
+
const multer_1 = __importDefault(require("multer"));
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const bad_request_error_1 = require("../errors/bad-request-error");
|
|
10
|
+
const globalUploadMiddleware = (options) => (0, multer_1.default)({
|
|
11
|
+
storage: multer_1.default.memoryStorage(),
|
|
12
|
+
fileFilter(req, file, callback) {
|
|
13
|
+
if (!file.mimetype.startsWith((options === null || options === void 0 ? void 0 : options.fileType) || 'image'))
|
|
14
|
+
return callback(new bad_request_error_1.BadRequestError('invalid file format'));
|
|
15
|
+
if (file.size > ((options === null || options === void 0 ? void 0 : options.maxSize) || 2 * 1024 * 1024))
|
|
16
|
+
return callback(new bad_request_error_1.BadRequestError('invalid file size'));
|
|
17
|
+
const splittedOriginalName = file.originalname.split('.').at(-1);
|
|
18
|
+
file.filename = `${(0, uuid_1.v4)()}.${splittedOriginalName}`;
|
|
19
|
+
callback(null, true);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
exports.globalUploadMiddleware = globalUploadMiddleware;
|
package/package.json
CHANGED
|
@@ -1,46 +1,48 @@
|
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"eslint
|
|
42
|
-
"eslint-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@duvdu-v1/duvdu",
|
|
3
|
+
"version": "1.0.27",
|
|
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
|
+
"uuid": "^9.0.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/uuid": "^9.0.8",
|
|
40
|
+
"del-cli": "^5.1.0",
|
|
41
|
+
"eslint": "^8.56.0",
|
|
42
|
+
"eslint-config-prettier": "^9.1.0",
|
|
43
|
+
"eslint-plugin-import": "^2.29.1",
|
|
44
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
45
|
+
"prettier": "^3.2.4"
|
|
46
|
+
},
|
|
47
|
+
"description": ""
|
|
48
|
+
}
|