bemoore-be-ticketing-common 1.0.8 → 3.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/dist/errors/bad-request-error.js +10 -28
- package/dist/errors/custom-error.d.ts +2 -2
- package/dist/errors/custom-error.js +5 -23
- package/dist/errors/database-connection-error.d.ts +3 -3
- package/dist/errors/database-connection-error.js +13 -31
- package/dist/errors/not-authorized-error.js +15 -0
- package/dist/errors/not-found-error.js +9 -27
- package/dist/errors/request-validation-error.d.ts +1 -1
- package/dist/errors/request-validation-error.js +17 -33
- package/dist/index.d.ts +10 -3
- package/dist/index.js +10 -3
- package/dist/middlewares/current-user.d.ts +6 -2
- package/dist/middlewares/current-user.js +6 -5
- package/dist/middlewares/error-handler.js +5 -7
- package/dist/middlewares/require-auth.js +3 -3
- package/dist/middlewares/validate-request.d.ts +2 -0
- package/dist/middlewares/validate-request.js +13 -0
- package/package.json +13 -17
- package/dist/errors/index.d.ts +0 -7
- package/dist/errors/index.js +0 -15
- package/dist/errors/not-authorized.js +0 -33
- package/dist/interfaces/index.d.ts +0 -4
- package/dist/interfaces/index.js +0 -2
- package/dist/middlewares/index.d.ts +0 -4
- package/dist/middlewares/index.js +0 -9
- /package/dist/errors/{not-authorized.d.ts → not-authorized-error.d.ts} +0 -0
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.BadRequestError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Object.setPrototypeOf(_this, BadRequestError.prototype);
|
|
27
|
-
return _this;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class BadRequestError extends custom_error_1.CustomError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.statusCode = 400;
|
|
10
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
28
11
|
}
|
|
29
|
-
|
|
12
|
+
serializeErrors() {
|
|
30
13
|
return [{ message: this.message }];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
}(custom_error_1.CustomError));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
34
16
|
exports.BadRequestError = BadRequestError;
|
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.CustomError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
Object.setPrototypeOf(_this, CustomError.prototype);
|
|
24
|
-
return _this;
|
|
4
|
+
class CustomError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
Object.setPrototypeOf(this, CustomError.prototype);
|
|
25
8
|
}
|
|
26
|
-
|
|
27
|
-
}(Error));
|
|
9
|
+
}
|
|
28
10
|
exports.CustomError = CustomError;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CustomError } from './custom-error';
|
|
2
|
-
export declare class
|
|
3
|
-
reason: string;
|
|
2
|
+
export declare class DatabaseConnectionError extends CustomError {
|
|
4
3
|
statusCode: number;
|
|
4
|
+
reason: string;
|
|
5
5
|
constructor();
|
|
6
|
-
serializeErrors
|
|
6
|
+
serializeErrors(): {
|
|
7
7
|
message: string;
|
|
8
8
|
}[];
|
|
9
9
|
}
|
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
_this.serializeErrors = function () {
|
|
27
|
-
return [{ message: _this.reason }];
|
|
28
|
-
};
|
|
29
|
-
Object.setPrototypeOf(_this, DatabaseConnextionError.prototype);
|
|
30
|
-
return _this;
|
|
3
|
+
exports.DatabaseConnectionError = void 0;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class DatabaseConnectionError extends custom_error_1.CustomError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Error connecting to db');
|
|
8
|
+
this.statusCode = 500;
|
|
9
|
+
this.reason = 'Error connecting to database';
|
|
10
|
+
Object.setPrototypeOf(this, DatabaseConnectionError.prototype);
|
|
31
11
|
}
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
12
|
+
serializeErrors() {
|
|
13
|
+
return [{ message: this.reason }];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.DatabaseConnectionError = DatabaseConnectionError;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotAuthorizedError = void 0;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class NotAuthorizedError extends custom_error_1.CustomError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Not Authorized');
|
|
8
|
+
this.statusCode = 401;
|
|
9
|
+
Object.setPrototypeOf(this, NotAuthorizedError.prototype);
|
|
10
|
+
}
|
|
11
|
+
serializeErrors() {
|
|
12
|
+
return [{ message: 'Not authorized' }];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.NotAuthorizedError = NotAuthorizedError;
|
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.NotFoundError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Object.setPrototypeOf(_this, NotFoundError.prototype);
|
|
26
|
-
return _this;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class NotFoundError extends custom_error_1.CustomError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('Route not found');
|
|
8
|
+
this.statusCode = 404;
|
|
9
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
27
10
|
}
|
|
28
|
-
|
|
11
|
+
serializeErrors() {
|
|
29
12
|
return [{ message: 'Not Found' }];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
}(custom_error_1.CustomError));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
33
15
|
exports.NotFoundError = NotFoundError;
|
|
@@ -1,38 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.RequestValidationError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return _this.errors.map(function (error) {
|
|
28
|
-
if (error.type === 'field') {
|
|
29
|
-
return { message: error.msg, field: error.path };
|
|
30
|
-
}
|
|
31
|
-
return { message: error.msg };
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
return _this;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class RequestValidationError extends custom_error_1.CustomError {
|
|
6
|
+
constructor(errors) {
|
|
7
|
+
super('Invalid request parameters');
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
this.statusCode = 400;
|
|
10
|
+
// Only because we are extending a built in class
|
|
11
|
+
Object.setPrototypeOf(this, RequestValidationError.prototype);
|
|
35
12
|
}
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
serializeErrors() {
|
|
14
|
+
return this.errors.map((err) => {
|
|
15
|
+
if (err.type === 'field') {
|
|
16
|
+
return { message: err.msg, field: err.path };
|
|
17
|
+
}
|
|
18
|
+
return { message: err.msg };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
38
22
|
exports.RequestValidationError = RequestValidationError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
export * from './errors';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './errors/bad-request-error';
|
|
2
|
+
export * from './errors/custom-error';
|
|
3
|
+
export * from './errors/database-connection-error';
|
|
4
|
+
export * from './errors/not-authorized-error';
|
|
5
|
+
export * from './errors/not-found-error';
|
|
6
|
+
export * from './errors/request-validation-error';
|
|
7
|
+
export * from './middlewares/current-user';
|
|
8
|
+
export * from './middlewares/error-handler';
|
|
9
|
+
export * from './middlewares/require-auth';
|
|
10
|
+
export * from './middlewares/validate-request';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./errors/bad-request-error"), exports);
|
|
18
|
+
__exportStar(require("./errors/custom-error"), exports);
|
|
19
|
+
__exportStar(require("./errors/database-connection-error"), exports);
|
|
20
|
+
__exportStar(require("./errors/not-authorized-error"), exports);
|
|
21
|
+
__exportStar(require("./errors/not-found-error"), exports);
|
|
22
|
+
__exportStar(require("./errors/request-validation-error"), exports);
|
|
23
|
+
__exportStar(require("./middlewares/current-user"), exports);
|
|
24
|
+
__exportStar(require("./middlewares/error-handler"), exports);
|
|
25
|
+
__exportStar(require("./middlewares/require-auth"), exports);
|
|
26
|
+
__exportStar(require("./middlewares/validate-request"), exports);
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
|
|
2
|
+
interface UserPayload {
|
|
3
|
+
id: string;
|
|
4
|
+
email: string;
|
|
5
|
+
}
|
|
3
6
|
declare global {
|
|
4
7
|
namespace Express {
|
|
5
8
|
interface Request {
|
|
6
|
-
currentUser?:
|
|
9
|
+
currentUser?: UserPayload;
|
|
7
10
|
}
|
|
8
11
|
}
|
|
9
12
|
}
|
|
10
13
|
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
14
|
+
export {};
|
|
@@ -4,16 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.currentUser = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const currentUser = (req, res, next) => {
|
|
9
9
|
var _a;
|
|
10
|
-
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt))
|
|
10
|
+
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
11
11
|
return next();
|
|
12
|
+
}
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
+
const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
14
15
|
req.currentUser = payload;
|
|
15
16
|
}
|
|
16
|
-
catch (
|
|
17
|
+
catch (err) { }
|
|
17
18
|
next();
|
|
18
19
|
};
|
|
19
20
|
exports.currentUser = currentUser;
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (err instanceof
|
|
7
|
-
return res.status(err.statusCode).send({
|
|
8
|
-
errors: err.serializeErrors(),
|
|
9
|
-
});
|
|
4
|
+
const custom_error_1 = require("../errors/custom-error");
|
|
5
|
+
const errorHandler = (err, req, res, next) => {
|
|
6
|
+
if (err instanceof custom_error_1.CustomError) {
|
|
7
|
+
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
10
8
|
}
|
|
11
9
|
res.status(400).send({
|
|
12
|
-
errors: [{ message: 'Something went wrong' }]
|
|
10
|
+
errors: [{ message: 'Something went wrong' }]
|
|
13
11
|
});
|
|
14
12
|
};
|
|
15
13
|
exports.errorHandler = errorHandler;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.requireAuth = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
5
|
+
const requireAuth = (req, res, next) => {
|
|
6
6
|
if (!req.currentUser) {
|
|
7
|
-
throw new
|
|
7
|
+
throw new not_authorized_error_1.NotAuthorizedError();
|
|
8
8
|
}
|
|
9
9
|
next();
|
|
10
10
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateRequest = void 0;
|
|
4
|
+
const express_validator_1 = require("express-validator");
|
|
5
|
+
const request_validation_error_1 = require("../errors/request-validation-error");
|
|
6
|
+
const validateRequest = (req, res, next) => {
|
|
7
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
8
|
+
if (!errors.isEmpty()) {
|
|
9
|
+
throw new request_validation_error_1.RequestValidationError(errors.array());
|
|
10
|
+
}
|
|
11
|
+
next();
|
|
12
|
+
};
|
|
13
|
+
exports.validateRequest = validateRequest;
|
package/package.json
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bemoore-be-ticketing-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist/**/*"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "del-cli dist",
|
|
12
12
|
"build": "npm run clean && tsc",
|
|
13
|
-
"
|
|
14
|
-
"pub": "npm run patch && npm publish"
|
|
13
|
+
"pub": "git add . && git commit -m \"Updates\" && npm version patch && npm run build && npm publish"
|
|
15
14
|
},
|
|
16
|
-
"keywords": [
|
|
17
|
-
"typescript",
|
|
18
|
-
"npm",
|
|
19
|
-
"module"
|
|
20
|
-
],
|
|
15
|
+
"keywords": [],
|
|
21
16
|
"author": "",
|
|
22
17
|
"license": "ISC",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"del-cli": "^5.1.0",
|
|
20
|
+
"typescript": "^5.6.2"
|
|
21
|
+
},
|
|
23
22
|
"dependencies": {
|
|
24
23
|
"@types/cookie-session": "^2.0.49",
|
|
25
24
|
"@types/express": "^5.0.0",
|
|
26
25
|
"@types/jsonwebtoken": "^9.0.7",
|
|
27
|
-
"
|
|
28
|
-
"express
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"del-cli": "^6.0.0"
|
|
26
|
+
"cookie-session": "^2.1.0",
|
|
27
|
+
"express": "^4.21.0",
|
|
28
|
+
"express-validator": "^7.2.0",
|
|
29
|
+
"jsonwebtoken": "^9.0.2"
|
|
34
30
|
}
|
|
35
31
|
}
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BadRequestError } from './bad-request-error';
|
|
2
|
-
import { CustomError } from './custom-error';
|
|
3
|
-
import { DatabaseConnextionError } from './database-connection-error';
|
|
4
|
-
import { NotAuthorizedError } from './not-authorized';
|
|
5
|
-
import { NotFoundError } from './not-found-error';
|
|
6
|
-
import { RequestValidationError } from './request-validation-error';
|
|
7
|
-
export { BadRequestError, CustomError, DatabaseConnextionError, NotAuthorizedError, NotFoundError, RequestValidationError, };
|
package/dist/errors/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RequestValidationError = exports.NotFoundError = exports.NotAuthorizedError = exports.DatabaseConnextionError = exports.CustomError = exports.BadRequestError = void 0;
|
|
4
|
-
var bad_request_error_1 = require("./bad-request-error");
|
|
5
|
-
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return bad_request_error_1.BadRequestError; } });
|
|
6
|
-
var custom_error_1 = require("./custom-error");
|
|
7
|
-
Object.defineProperty(exports, "CustomError", { enumerable: true, get: function () { return custom_error_1.CustomError; } });
|
|
8
|
-
var database_connection_error_1 = require("./database-connection-error");
|
|
9
|
-
Object.defineProperty(exports, "DatabaseConnextionError", { enumerable: true, get: function () { return database_connection_error_1.DatabaseConnextionError; } });
|
|
10
|
-
var not_authorized_1 = require("./not-authorized");
|
|
11
|
-
Object.defineProperty(exports, "NotAuthorizedError", { enumerable: true, get: function () { return not_authorized_1.NotAuthorizedError; } });
|
|
12
|
-
var not_found_error_1 = require("./not-found-error");
|
|
13
|
-
Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return not_found_error_1.NotFoundError; } });
|
|
14
|
-
var request_validation_error_1 = require("./request-validation-error");
|
|
15
|
-
Object.defineProperty(exports, "RequestValidationError", { enumerable: true, get: function () { return request_validation_error_1.RequestValidationError; } });
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.NotAuthorizedError = void 0;
|
|
19
|
-
var custom_error_1 = require("./custom-error");
|
|
20
|
-
var NotAuthorizedError = /** @class */ (function (_super) {
|
|
21
|
-
__extends(NotAuthorizedError, _super);
|
|
22
|
-
function NotAuthorizedError() {
|
|
23
|
-
var _this = _super.call(this, 'Not authorized') || this;
|
|
24
|
-
_this.statusCode = 401;
|
|
25
|
-
Object.setPrototypeOf(_this, NotAuthorizedError.prototype);
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
NotAuthorizedError.prototype.serializeErrors = function () {
|
|
29
|
-
return [{ message: 'Not authorized' }];
|
|
30
|
-
};
|
|
31
|
-
return NotAuthorizedError;
|
|
32
|
-
}(custom_error_1.CustomError));
|
|
33
|
-
exports.NotAuthorizedError = NotAuthorizedError;
|
package/dist/interfaces/index.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireAuth = exports.errorHandler = exports.currentUser = void 0;
|
|
4
|
-
var current_user_1 = require("./current-user");
|
|
5
|
-
Object.defineProperty(exports, "currentUser", { enumerable: true, get: function () { return current_user_1.currentUser; } });
|
|
6
|
-
var error_handler_1 = require("./error-handler");
|
|
7
|
-
Object.defineProperty(exports, "errorHandler", { enumerable: true, get: function () { return error_handler_1.errorHandler; } });
|
|
8
|
-
var require_auth_1 = require("./require-auth");
|
|
9
|
-
Object.defineProperty(exports, "requireAuth", { enumerable: true, get: function () { return require_auth_1.requireAuth; } });
|
|
File without changes
|