@aichatwar/shared 1.0.8 → 1.0.9
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/package.json +1 -1
- package/build/errors/badRequestError.d.ts +0 -12
- package/build/errors/badRequestError.js +0 -21
- package/build/errors/customError.d.ts +0 -9
- package/build/errors/customError.js +0 -10
- package/build/errors/databaseError.d.ts +0 -11
- package/build/errors/databaseError.js +0 -17
- package/build/errors/notAuthorizedError.d.ts +0 -11
- package/build/errors/notAuthorizedError.js +0 -17
- package/build/errors/notfoundError.d.ts +0 -11
- package/build/errors/notfoundError.js +0 -16
- package/build/errors/requestValidationError.d.ts +0 -16
- package/build/errors/requestValidationError.js +0 -23
- package/build/index.d.ts +0 -10
- package/build/index.js +0 -26
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CustomError } from "./customError";
|
|
2
|
-
declare class BadRequestError extends CustomError {
|
|
3
|
-
details: string;
|
|
4
|
-
data: string;
|
|
5
|
-
statusCode: number;
|
|
6
|
-
constructor(details: string);
|
|
7
|
-
serializeDetails(): {
|
|
8
|
-
message: string;
|
|
9
|
-
field?: string;
|
|
10
|
-
}[];
|
|
11
|
-
}
|
|
12
|
-
export { BadRequestError };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BadRequestError = void 0;
|
|
4
|
-
const customError_1 = require("./customError");
|
|
5
|
-
class BadRequestError extends customError_1.CustomError {
|
|
6
|
-
constructor(details) {
|
|
7
|
-
super(details);
|
|
8
|
-
this.details = details;
|
|
9
|
-
this.data = "Bad Request!";
|
|
10
|
-
this.statusCode = 400;
|
|
11
|
-
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
12
|
-
}
|
|
13
|
-
serializeDetails() {
|
|
14
|
-
return [
|
|
15
|
-
{ message: this.details
|
|
16
|
-
}
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
;
|
|
20
|
-
}
|
|
21
|
-
exports.BadRequestError = BadRequestError;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomError = void 0;
|
|
4
|
-
class CustomError extends Error {
|
|
5
|
-
constructor(errorMessage) {
|
|
6
|
-
super(errorMessage);
|
|
7
|
-
Object.setPrototypeOf(this, CustomError.prototype);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.CustomError = CustomError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CustomError } from "./customError";
|
|
2
|
-
declare class DatabaseError extends CustomError {
|
|
3
|
-
details: string[];
|
|
4
|
-
data: string;
|
|
5
|
-
statusCode: number;
|
|
6
|
-
constructor(details: string[]);
|
|
7
|
-
serializeDetails(): {
|
|
8
|
-
message: string;
|
|
9
|
-
}[];
|
|
10
|
-
}
|
|
11
|
-
export { DatabaseError };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseError = void 0;
|
|
4
|
-
const customError_1 = require("./customError");
|
|
5
|
-
class DatabaseError extends customError_1.CustomError {
|
|
6
|
-
constructor(details) {
|
|
7
|
-
super('Database error');
|
|
8
|
-
this.details = details;
|
|
9
|
-
this.data = 'Database error';
|
|
10
|
-
this.statusCode = 500;
|
|
11
|
-
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
12
|
-
}
|
|
13
|
-
serializeDetails() {
|
|
14
|
-
return [{ message: this.data }];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.DatabaseError = DatabaseError;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { CustomError } from "./customError";
|
|
2
|
-
declare class NotAuthorizedError extends CustomError {
|
|
3
|
-
details: string[];
|
|
4
|
-
data: string;
|
|
5
|
-
statusCode: number;
|
|
6
|
-
constructor(details: string[]);
|
|
7
|
-
serializeDetails(): {
|
|
8
|
-
message: string;
|
|
9
|
-
}[];
|
|
10
|
-
}
|
|
11
|
-
export { NotAuthorizedError };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotAuthorizedError = void 0;
|
|
4
|
-
const customError_1 = require("./customError");
|
|
5
|
-
class NotAuthorizedError extends customError_1.CustomError {
|
|
6
|
-
constructor(details) {
|
|
7
|
-
super('not Authorized');
|
|
8
|
-
this.details = details;
|
|
9
|
-
this.data = 'not Authorized';
|
|
10
|
-
this.statusCode = 401;
|
|
11
|
-
Object.setPrototypeOf(this, NotAuthorizedError.prototype);
|
|
12
|
-
}
|
|
13
|
-
serializeDetails() {
|
|
14
|
-
return [{ message: this.data }];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.NotAuthorizedError = NotAuthorizedError;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotFoundError = void 0;
|
|
4
|
-
const customError_1 = require("./customError");
|
|
5
|
-
class NotFoundError extends customError_1.CustomError {
|
|
6
|
-
constructor() {
|
|
7
|
-
super("Rout not found!");
|
|
8
|
-
this.data = "not found!";
|
|
9
|
-
this.statusCode = 404;
|
|
10
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
11
|
-
}
|
|
12
|
-
serializeDetails() {
|
|
13
|
-
return [{ message: "not found" }];
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.NotFoundError = NotFoundError;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { CustomError } from "./customError";
|
|
2
|
-
import { ValidationError } from "express-validator";
|
|
3
|
-
declare class RequestValidationError extends CustomError {
|
|
4
|
-
details: ValidationError[];
|
|
5
|
-
data: string;
|
|
6
|
-
statusCode: number;
|
|
7
|
-
constructor(details: ValidationError[]);
|
|
8
|
-
serializeDetails(): ({
|
|
9
|
-
message: any;
|
|
10
|
-
field: string;
|
|
11
|
-
} | {
|
|
12
|
-
message: any;
|
|
13
|
-
field?: undefined;
|
|
14
|
-
})[];
|
|
15
|
-
}
|
|
16
|
-
export { RequestValidationError };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestValidationError = void 0;
|
|
4
|
-
const customError_1 = require("./customError");
|
|
5
|
-
class RequestValidationError extends customError_1.CustomError {
|
|
6
|
-
constructor(details) {
|
|
7
|
-
super('Invalid request');
|
|
8
|
-
this.details = details;
|
|
9
|
-
this.data = "Invalid request!";
|
|
10
|
-
this.statusCode = 400;
|
|
11
|
-
// extending a built in class
|
|
12
|
-
Object.setPrototypeOf(this, RequestValidationError.prototype);
|
|
13
|
-
}
|
|
14
|
-
serializeDetails() {
|
|
15
|
-
return this.details.map(detail => {
|
|
16
|
-
if (detail.type == 'field') {
|
|
17
|
-
return { message: detail.msg, field: detail.path };
|
|
18
|
-
}
|
|
19
|
-
return { message: detail.msg };
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.RequestValidationError = RequestValidationError;
|
package/build/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from "./errors/badRequestError";
|
|
2
|
-
export * from "./errors/customError";
|
|
3
|
-
export * from "./errors/databaseError";
|
|
4
|
-
export * from "./errors/notAuthorizedError";
|
|
5
|
-
export * from "./errors/notfoundError";
|
|
6
|
-
export * from "./errors/requestValidationError";
|
|
7
|
-
export * from "./middlewares/error-handler";
|
|
8
|
-
export * from "./middlewares/jwt-extractor";
|
|
9
|
-
export * from "./middlewares/login-required";
|
|
10
|
-
export * from "./middlewares/validate-request";
|
package/build/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors/badRequestError"), exports);
|
|
18
|
-
__exportStar(require("./errors/customError"), exports);
|
|
19
|
-
__exportStar(require("./errors/databaseError"), exports);
|
|
20
|
-
__exportStar(require("./errors/notAuthorizedError"), exports);
|
|
21
|
-
__exportStar(require("./errors/notfoundError"), exports);
|
|
22
|
-
__exportStar(require("./errors/requestValidationError"), exports);
|
|
23
|
-
__exportStar(require("./middlewares/error-handler"), exports);
|
|
24
|
-
__exportStar(require("./middlewares/jwt-extractor"), exports);
|
|
25
|
-
__exportStar(require("./middlewares/login-required"), exports);
|
|
26
|
-
__exportStar(require("./middlewares/validate-request"), exports);
|