@duvdu-v1/duvdu 1.0.19 → 1.0.21
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CustomError } from './custom-error';
|
|
2
2
|
export declare class GenericError extends CustomError {
|
|
3
3
|
statusCode: number;
|
|
4
|
-
constructor(message: string
|
|
4
|
+
constructor(message: string);
|
|
5
5
|
serializeError(): {
|
|
6
6
|
message: string;
|
|
7
7
|
field?: string | undefined;
|
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GenericError = void 0;
|
|
4
4
|
const custom_error_1 = require("./custom-error");
|
|
5
5
|
class GenericError extends custom_error_1.CustomError {
|
|
6
|
-
constructor(message
|
|
6
|
+
constructor(message) {
|
|
7
7
|
super(message);
|
|
8
|
-
this.statusCode =
|
|
8
|
+
this.statusCode = 406;
|
|
9
|
+
Object.setPrototypeOf(this, GenericError.prototype);
|
|
9
10
|
}
|
|
10
11
|
serializeError() {
|
|
11
12
|
return [{ message: this.message }];
|
package/build/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './errors/notfound-error';
|
|
|
7
7
|
export * from './errors/unauthenticated-error';
|
|
8
8
|
export * from './errors/unauthorized-error';
|
|
9
9
|
export * from './errors/validation-error';
|
|
10
|
+
export * from './errors/generic-error';
|
|
10
11
|
export * from './middlewares/global-error-handling.middleware';
|
|
11
12
|
export * from './utils/api-feature';
|
|
12
13
|
export * from './middlewares/database-connection';
|
package/build/index.js
CHANGED
|
@@ -24,6 +24,7 @@ __exportStar(require("./errors/notfound-error"), exports);
|
|
|
24
24
|
__exportStar(require("./errors/unauthenticated-error"), exports);
|
|
25
25
|
__exportStar(require("./errors/unauthorized-error"), exports);
|
|
26
26
|
__exportStar(require("./errors/validation-error"), exports);
|
|
27
|
+
__exportStar(require("./errors/generic-error"), exports);
|
|
27
28
|
__exportStar(require("./middlewares/global-error-handling.middleware"), exports);
|
|
28
29
|
// export * from "./types/Pagination";
|
|
29
30
|
// export * from "./types/UrlQuery";
|
|
@@ -21,10 +21,10 @@ const unauthenticated_error_1 = require("../errors/unauthenticated-error");
|
|
|
21
21
|
const auth = (modelName) => ((req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
22
|
var _a, _b;
|
|
23
23
|
const user = yield modelName.findOne({ token: (_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt });
|
|
24
|
-
if (user.isBlocked
|
|
25
|
-
|
|
24
|
+
if (user.isBlocked) {
|
|
25
|
+
throw new generic_error_1.GenericError('the users access is denied due to their blocked status.');
|
|
26
26
|
}
|
|
27
|
-
if (!((_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt)
|
|
27
|
+
if (!((_b = req.session) === null || _b === void 0 ? void 0 : _b.jwt) || !user) {
|
|
28
28
|
throw new unauthenticated_error_1.UnauthenticatedError();
|
|
29
29
|
}
|
|
30
30
|
try {
|