@duvdu-v1/duvdu 1.0.2 → 1.0.5
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/bad-request-error.js +1 -1
- package/build/errors/data-base-connections.d.ts +2 -2
- package/build/errors/data-base-connections.js +5 -6
- package/build/errors/notfound-error.d.ts +1 -1
- package/build/errors/notfound-error.js +2 -2
- package/build/errors/unauthenticated-error.d.ts +1 -1
- package/build/errors/unauthenticated-error.js +2 -2
- package/build/errors/unauthorized-error.d.ts +1 -1
- package/build/errors/unauthorized-error.js +2 -2
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/middlewares/database-connection.js +5 -2
- package/build/middlewares/global-validator.middleware.d.ts +2 -0
- package/build/middlewares/global-validator.middleware.js +12 -0
- package/package.json +12 -10
|
@@ -4,7 +4,7 @@ exports.BadRequestError = void 0;
|
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class BadRequestError extends custom_error_1.CustomError {
|
|
6
6
|
constructor(message) {
|
|
7
|
-
super(message);
|
|
7
|
+
super(message || 'bad-request error');
|
|
8
8
|
this.statusCode = 400;
|
|
9
9
|
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
10
10
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CustomError } from
|
|
1
|
+
import { CustomError } from './custom-error';
|
|
2
2
|
export declare class DatabaseConnectionError extends CustomError {
|
|
3
3
|
statusCode: number;
|
|
4
4
|
reason: string;
|
|
5
|
-
constructor();
|
|
5
|
+
constructor(message?: string);
|
|
6
6
|
serializeError(): {
|
|
7
7
|
message: string;
|
|
8
8
|
}[];
|
|
@@ -3,19 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DatabaseConnectionError = void 0;
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class DatabaseConnectionError extends custom_error_1.CustomError {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || 'Error connecting to database');
|
|
8
8
|
this.statusCode = 500;
|
|
9
|
-
this.reason =
|
|
9
|
+
this.reason = 'Error connecting to database';
|
|
10
10
|
Object.setPrototypeOf(this, DatabaseConnectionError.prototype);
|
|
11
11
|
}
|
|
12
12
|
serializeError() {
|
|
13
13
|
return [
|
|
14
14
|
{
|
|
15
|
-
message: this.reason
|
|
16
|
-
}
|
|
15
|
+
message: this.reason,
|
|
16
|
+
},
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
|
-
;
|
|
20
19
|
}
|
|
21
20
|
exports.DatabaseConnectionError = DatabaseConnectionError;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.NotFound = void 0;
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class NotFound extends custom_error_1.CustomError {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('not found error');
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || 'not found error');
|
|
8
8
|
this.statusCode = 404;
|
|
9
9
|
Object.setPrototypeOf(this, NotFound.prototype);
|
|
10
10
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UnauthenticatedError = void 0;
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class UnauthenticatedError extends custom_error_1.CustomError {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('un-authenticated error');
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || 'un-authenticated error');
|
|
8
8
|
this.statusCode = 401;
|
|
9
9
|
Object.setPrototypeOf(this, UnauthenticatedError.prototype);
|
|
10
10
|
}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UnauthorizedError = void 0;
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class UnauthorizedError extends custom_error_1.CustomError {
|
|
6
|
-
constructor() {
|
|
7
|
-
super('un-unauthorized error');
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || 'un-unauthorized error');
|
|
8
8
|
this.statusCode = 403;
|
|
9
9
|
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
10
10
|
}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -29,3 +29,4 @@ __exportStar(require("./middlewares/global-error-handling.middleware"), exports)
|
|
|
29
29
|
// export * from "./types/UrlQuery";
|
|
30
30
|
__exportStar(require("./utils/api-feature"), exports);
|
|
31
31
|
__exportStar(require("./middlewares/database-connection"), exports);
|
|
32
|
+
__exportStar(require("./types/JwtPayload"), exports);
|
|
@@ -7,9 +7,12 @@ exports.dbConnection = void 0;
|
|
|
7
7
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
8
8
|
const data_base_connections_1 = require("../errors/data-base-connections");
|
|
9
9
|
const dbConnection = (URI) => {
|
|
10
|
-
return mongoose_1.default
|
|
10
|
+
return mongoose_1.default
|
|
11
|
+
.connect(URI)
|
|
12
|
+
.then((conn) => {
|
|
11
13
|
console.log(`database connected in : ${conn.connection.host}`);
|
|
12
|
-
})
|
|
14
|
+
})
|
|
15
|
+
.catch(() => {
|
|
13
16
|
throw new data_base_connections_1.DatabaseConnectionError();
|
|
14
17
|
});
|
|
15
18
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalValidatorMiddleware = void 0;
|
|
4
|
+
const express_validator_1 = require("express-validator");
|
|
5
|
+
const validation_error_1 = require("../errors/validation-error");
|
|
6
|
+
const globalValidatorMiddleware = (req, res, next) => {
|
|
7
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
8
|
+
if (!errors.isEmpty())
|
|
9
|
+
return next(new validation_error_1.ValidationError(errors.array()));
|
|
10
|
+
next();
|
|
11
|
+
};
|
|
12
|
+
exports.globalValidatorMiddleware = globalValidatorMiddleware;
|
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duvdu-v1/duvdu",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.5",
|
|
5
4
|
"main": "./build/index.js",
|
|
6
5
|
"types": "./build/index.d.ts",
|
|
7
6
|
"files": [
|
|
@@ -19,24 +18,27 @@
|
|
|
19
18
|
"author": "motemed khaled",
|
|
20
19
|
"license": "ISC",
|
|
21
20
|
"dependencies": {
|
|
21
|
+
"@duvdu-v1/duvdu": "^1.0.2",
|
|
22
|
+
"@types/express": "^4.17.21",
|
|
23
|
+
"@types/multer": "^1.4.11",
|
|
22
24
|
"@types/node": "^20.11.0",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
26
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
23
27
|
"express": "^4.18.2",
|
|
24
28
|
"express-validator": "^7.0.1",
|
|
25
29
|
"mongoose": "^8.0.4",
|
|
26
30
|
"multer": "^1.4.5-lts.1",
|
|
27
|
-
"node-nats-streaming": "^0.3.2"
|
|
31
|
+
"node-nats-streaming": "^0.3.2",
|
|
32
|
+
"rimraf": "^5.0.5",
|
|
33
|
+
"typescript": "^5.3.3"
|
|
28
34
|
},
|
|
29
35
|
"devDependencies": {
|
|
30
|
-
"@types/express": "^4.17.21",
|
|
31
|
-
"@types/multer": "^1.4.11",
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
33
|
-
"@typescript-eslint/parser": "^6.19.0",
|
|
34
36
|
"del-cli": "^5.1.0",
|
|
35
37
|
"eslint": "^8.56.0",
|
|
36
38
|
"eslint-config-prettier": "^9.1.0",
|
|
37
39
|
"eslint-plugin-import": "^2.29.1",
|
|
38
40
|
"eslint-plugin-prettier": "^5.1.3",
|
|
39
|
-
"prettier": "^3.2.4"
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
"prettier": "^3.2.4"
|
|
42
|
+
},
|
|
43
|
+
"description": ""
|
|
42
44
|
}
|