@tjticketing/common 1.0.2 → 1.0.3
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.d.ts +11 -0
- package/build/errors/bad-request-error.d.ts.map +1 -0
- package/build/errors/bad-request-error.js +37 -0
- package/build/errors/bad-request-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +9 -0
- package/build/errors/custom-error.d.ts.map +1 -0
- package/build/errors/custom-error.js +29 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/database-connection-error.d.ts +10 -0
- package/build/errors/database-connection-error.d.ts.map +1 -0
- package/build/errors/database-connection-error.js +35 -0
- package/build/errors/database-connection-error.js.map +1 -0
- package/build/errors/not-authorized-error.d.ts +10 -0
- package/build/errors/not-authorized-error.d.ts.map +1 -0
- package/build/errors/not-authorized-error.js +36 -0
- package/build/errors/not-authorized-error.js.map +1 -0
- package/build/errors/not-found-error.d.ts +10 -0
- package/build/errors/not-found-error.d.ts.map +1 -0
- package/build/errors/not-found-error.js +36 -0
- package/build/errors/not-found-error.js.map +1 -0
- package/build/errors/request-validation-error.d.ts +15 -0
- package/build/errors/request-validation-error.d.ts.map +1 -0
- package/build/errors/request-validation-error.js +44 -0
- package/build/errors/request-validation-error.js.map +1 -0
- package/build/index.d.ts +10 -7
- package/build/index.d.ts.map +1 -1
- package/build/index.js +24 -7
- package/build/index.js.map +1 -1
- package/build/middleware/current-user.d.ts +16 -0
- package/build/middleware/current-user.d.ts.map +1 -0
- package/build/middleware/current-user.js +20 -0
- package/build/middleware/current-user.js.map +1 -0
- package/build/middleware/error-handler.d.ts +3 -0
- package/build/middleware/error-handler.d.ts.map +1 -0
- package/build/middleware/error-handler.js +16 -0
- package/build/middleware/error-handler.js.map +1 -0
- package/build/middleware/require-auth.d.ts +3 -0
- package/build/middleware/require-auth.d.ts.map +1 -0
- package/build/middleware/require-auth.js +12 -0
- package/build/middleware/require-auth.js.map +1 -0
- package/build/middleware/validation-request.d.ts +3 -0
- package/build/middleware/validation-request.d.ts.map +1 -0
- package/build/middleware/validation-request.js +14 -0
- package/build/middleware/validation-request.js.map +1 -0
- package/package.json +10 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CustomError } from "./custom-error";
|
|
2
|
+
export declare class BadRequestError extends CustomError {
|
|
3
|
+
message: string;
|
|
4
|
+
statusCode: number;
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
serializeErrors(): {
|
|
7
|
+
message: string;
|
|
8
|
+
field?: string;
|
|
9
|
+
}[];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=bad-request-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bad-request-error.d.ts","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,eAAgB,SAAQ,WAAW;IAGzB,OAAO,EAAE,MAAM;IAFlC,UAAU,SAAO;gBAEE,OAAO,EAAE,MAAM;IAMlC,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KAAE,EAAE;CAK5D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.BadRequestError = void 0;
|
|
19
|
+
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var BadRequestError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(BadRequestError, _super);
|
|
22
|
+
function BadRequestError(message) {
|
|
23
|
+
var _this = _super.call(this, message) || this;
|
|
24
|
+
_this.message = message;
|
|
25
|
+
_this.statusCode = 400;
|
|
26
|
+
Object.setPrototypeOf(_this, BadRequestError.prototype);
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
BadRequestError.prototype.serializeErrors = function () {
|
|
30
|
+
return [{
|
|
31
|
+
message: this.message,
|
|
32
|
+
}];
|
|
33
|
+
};
|
|
34
|
+
return BadRequestError;
|
|
35
|
+
}(custom_error_1.CustomError));
|
|
36
|
+
exports.BadRequestError = BadRequestError;
|
|
37
|
+
//# sourceMappingURL=bad-request-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAE7C;IAAqC,mCAAW;IAG5C,yBAAmB,OAAe;QAC9B,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QADA,aAAO,GAAP,OAAO,CAAQ;QAFlC,gBAAU,GAAG,GAAG,CAAC;QAKb,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;;IAC3D,CAAC;IAED,yCAAe,GAAf;QACI,OAAO,CAAC;gBACJ,OAAO,EAAE,IAAI,CAAC,OAAO;aACxB,CAAC,CAAA;IACN,CAAC;IACL,sBAAC;AAAD,CAAC,AAdD,CAAqC,0BAAW,GAc/C;AAdY,0CAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-error.d.ts","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA,8BAAsB,WAAY,SAAQ,KAAK;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,MAAM;IAM3B,QAAQ,CAAC,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE;CACpE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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.CustomError = void 0;
|
|
19
|
+
var CustomError = /** @class */ (function (_super) {
|
|
20
|
+
__extends(CustomError, _super);
|
|
21
|
+
function CustomError(message) {
|
|
22
|
+
var _this = _super.call(this, message) || this;
|
|
23
|
+
Object.setPrototypeOf(_this, CustomError.prototype);
|
|
24
|
+
return _this;
|
|
25
|
+
}
|
|
26
|
+
return CustomError;
|
|
27
|
+
}(Error));
|
|
28
|
+
exports.CustomError = CustomError;
|
|
29
|
+
//# sourceMappingURL=custom-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;IAA0C,+BAAK;IAG3C,qBAAY,OAAe;QACvB,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QAEf,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;;IACvD,CAAC;IAGL,kBAAC;AAAD,CAAC,AAVD,CAA0C,KAAK,GAU9C;AAVqB,kCAAW"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomError } from "./custom-error";
|
|
2
|
+
export declare class DatabaseConnectionError extends CustomError {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
reason: string;
|
|
5
|
+
constructor();
|
|
6
|
+
serializeErrors(): {
|
|
7
|
+
message: string;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=database-connection-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-connection-error.d.ts","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,uBAAwB,SAAQ,WAAW;IACpD,UAAU,SAAO;IACjB,MAAM,SAAkC;;IAQxC,eAAe;;;CAGlB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.DatabaseConnectionError = void 0;
|
|
19
|
+
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var DatabaseConnectionError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(DatabaseConnectionError, _super);
|
|
22
|
+
function DatabaseConnectionError() {
|
|
23
|
+
var _this = _super.call(this, 'Error connecting to DB') || this;
|
|
24
|
+
_this.statusCode = 500;
|
|
25
|
+
_this.reason = 'Error connecting to database';
|
|
26
|
+
Object.setPrototypeOf(_this, DatabaseConnectionError.prototype);
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
DatabaseConnectionError.prototype.serializeErrors = function () {
|
|
30
|
+
return [{ message: this.reason }];
|
|
31
|
+
};
|
|
32
|
+
return DatabaseConnectionError;
|
|
33
|
+
}(custom_error_1.CustomError));
|
|
34
|
+
exports.DatabaseConnectionError = DatabaseConnectionError;
|
|
35
|
+
//# sourceMappingURL=database-connection-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database-connection-error.js","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAE7C;IAA6C,2CAAW;IAIpD;QACI,YAAA,MAAK,YAAC,wBAAwB,CAAC,SAAC;QAJpC,gBAAU,GAAG,GAAG,CAAC;QACjB,YAAM,GAAG,8BAA8B,CAAC;QAKpC,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;;IACnE,CAAC;IAED,iDAAe,GAAf;QACI,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACrC,CAAC;IACL,8BAAC;AAAD,CAAC,AAbD,CAA6C,0BAAW,GAavD;AAbY,0DAAuB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomError } from "./custom-error";
|
|
2
|
+
export declare class NotAuthorizedError extends CustomError {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
constructor();
|
|
5
|
+
serializeErrors(): {
|
|
6
|
+
message: string;
|
|
7
|
+
field?: string;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=not-authorized-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-authorized-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,kBAAmB,SAAQ,WAAW;IAC/C,UAAU,SAAO;;IAQjB,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KAAE,EAAE;CAK5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 [{
|
|
30
|
+
message: 'Not authorized'
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
return NotAuthorizedError;
|
|
34
|
+
}(custom_error_1.CustomError));
|
|
35
|
+
exports.NotAuthorizedError = NotAuthorizedError;
|
|
36
|
+
//# sourceMappingURL=not-authorized-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-authorized-error.js","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAE7C;IAAwC,sCAAW;IAG/C;QACI,YAAA,MAAK,YAAC,gBAAgB,CAAC,SAAC;QAH5B,gBAAU,GAAG,GAAG,CAAC;QAKb,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;;IAC9D,CAAC;IAED,4CAAe,GAAf;QACI,OAAO,CAAC;gBACJ,OAAO,EAAE,gBAAgB;aAC5B,CAAC,CAAA;IACN,CAAC;IACL,yBAAC;AAAD,CAAC,AAdD,CAAwC,0BAAW,GAclD;AAdY,gDAAkB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomError } from "./custom-error";
|
|
2
|
+
export declare class NotFoundError extends CustomError {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
constructor();
|
|
5
|
+
serializeErrors(): {
|
|
6
|
+
message: string;
|
|
7
|
+
field?: string;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=not-found-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found-error.d.ts","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,aAAc,SAAQ,WAAW;IAC1C,UAAU,SAAO;;IAQjB,eAAe,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;KAAE,EAAE;CAK5D"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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.NotFoundError = void 0;
|
|
19
|
+
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var NotFoundError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(NotFoundError, _super);
|
|
22
|
+
function NotFoundError() {
|
|
23
|
+
var _this = _super.call(this, 'Route not found') || this;
|
|
24
|
+
_this.statusCode = 404;
|
|
25
|
+
Object.setPrototypeOf(_this, NotFoundError.prototype);
|
|
26
|
+
return _this;
|
|
27
|
+
}
|
|
28
|
+
NotFoundError.prototype.serializeErrors = function () {
|
|
29
|
+
return [{
|
|
30
|
+
message: 'Not Found',
|
|
31
|
+
}];
|
|
32
|
+
};
|
|
33
|
+
return NotFoundError;
|
|
34
|
+
}(custom_error_1.CustomError));
|
|
35
|
+
exports.NotFoundError = NotFoundError;
|
|
36
|
+
//# sourceMappingURL=not-found-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"not-found-error.js","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+CAA6C;AAE7C;IAAmC,iCAAW;IAG1C;QACI,YAAA,MAAK,YAAC,iBAAiB,CAAC,SAAC;QAH7B,gBAAU,GAAG,GAAG,CAAC;QAKb,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;;IACzD,CAAC;IAED,uCAAe,GAAf;QACI,OAAO,CAAC;gBACJ,OAAO,EAAE,WAAW;aACvB,CAAC,CAAA;IACN,CAAC;IACL,oBAAC;AAAD,CAAC,AAdD,CAAmC,0BAAW,GAc7C;AAdY,sCAAa"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValidationError } from "express-validator";
|
|
2
|
+
import { CustomError } from "./custom-error";
|
|
3
|
+
export declare class RequestValidationError extends CustomError {
|
|
4
|
+
errors: ValidationError[];
|
|
5
|
+
statusCode: number;
|
|
6
|
+
constructor(errors: ValidationError[]);
|
|
7
|
+
serializeErrors(): ({
|
|
8
|
+
message: any;
|
|
9
|
+
field: string;
|
|
10
|
+
} | {
|
|
11
|
+
message: any;
|
|
12
|
+
field?: undefined;
|
|
13
|
+
})[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=request-validation-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-validation-error.d.ts","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,qBAAa,sBAAuB,SAAQ,WAAW;IAGhC,MAAM,EAAE,eAAe,EAAE;IAF5C,UAAU,SAAO;gBAEE,MAAM,EAAE,eAAe,EAAE;IAO5C,eAAe;;;;;;;CAYlB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
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.RequestValidationError = void 0;
|
|
19
|
+
var custom_error_1 = require("./custom-error");
|
|
20
|
+
var RequestValidationError = /** @class */ (function (_super) {
|
|
21
|
+
__extends(RequestValidationError, _super);
|
|
22
|
+
function RequestValidationError(errors) {
|
|
23
|
+
var _this = _super.call(this, 'Invalid request parameters') || this;
|
|
24
|
+
_this.errors = errors;
|
|
25
|
+
_this.statusCode = 400;
|
|
26
|
+
// Only because we are extending a built in class
|
|
27
|
+
Object.setPrototypeOf(_this, RequestValidationError.prototype);
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
RequestValidationError.prototype.serializeErrors = function () {
|
|
31
|
+
return this.errors.map(function (error) {
|
|
32
|
+
if (error.type === 'field') {
|
|
33
|
+
return {
|
|
34
|
+
message: error.msg,
|
|
35
|
+
field: error.path,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return { message: error.msg };
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
return RequestValidationError;
|
|
42
|
+
}(custom_error_1.CustomError));
|
|
43
|
+
exports.RequestValidationError = RequestValidationError;
|
|
44
|
+
//# sourceMappingURL=request-validation-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-validation-error.js","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,+CAA6C;AAE7C;IAA4C,0CAAW;IAGnD,gCAAmB,MAAyB;QACxC,YAAA,MAAK,YAAC,4BAA4B,CAAC,SAAC;QADrB,YAAM,GAAN,MAAM,CAAmB;QAF5C,gBAAU,GAAG,GAAG,CAAC;QAKb,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,KAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;;IAClE,CAAC;IAED,gDAAe,GAAf;QACI,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAA,KAAK;YACxB,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACzB,OAAO;oBACH,OAAO,EAAE,KAAK,CAAC,GAAG;oBAClB,KAAK,EAAE,KAAK,CAAC,IAAI;iBACpB,CAAA;YACL,CAAC;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,EAAE,CAAC;QAClC,CAAC,CAAC,CAAA;IACN,CAAC;IACL,6BAAC;AAAD,CAAC,AAtBD,CAA4C,0BAAW,GAsBtD;AAtBY,wDAAsB"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
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 './middleware/current-user';
|
|
8
|
+
export * from './middleware/error-handler';
|
|
9
|
+
export * from './middleware/require-auth';
|
|
10
|
+
export * from './middleware/validation-request';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,oCAAoC,CAAC;AACnD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAElD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
7
15
|
};
|
|
8
|
-
|
|
9
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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("./middleware/current-user"), exports);
|
|
24
|
+
__exportStar(require("./middleware/error-handler"), exports);
|
|
25
|
+
__exportStar(require("./middleware/require-auth"), exports);
|
|
26
|
+
__exportStar(require("./middleware/validation-request"), exports);
|
|
10
27
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6DAA2C;AAC3C,wDAAsC;AACtC,qEAAmD;AACnD,gEAA8C;AAC9C,2DAAyC;AACzC,oEAAkD;AAElD,4DAA0C;AAC1C,6DAA2C;AAC3C,4DAA0C;AAC1C,kEAAgD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Request, Response, NextFunction } from "express";
|
|
2
|
+
import 'cookie-session';
|
|
3
|
+
interface UserPayload {
|
|
4
|
+
id: string;
|
|
5
|
+
email: string;
|
|
6
|
+
}
|
|
7
|
+
declare global {
|
|
8
|
+
namespace Express {
|
|
9
|
+
interface Request {
|
|
10
|
+
currentUser?: UserPayload;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=current-user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.d.ts","sourceRoot":"","sources":["../../src/middleware/current-user.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,gBAAgB,CAAC;AAExB,UAAU,WAAW;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,OAAO,CAAC;QACd,UAAU,OAAO;YACb,WAAW,CAAC,EAAE,WAAW,CAAC;SAC7B;KACJ;CACJ;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAa1E,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentUser = void 0;
|
|
4
|
+
var jsonwebtoken_1 = require("jsonwebtoken");
|
|
5
|
+
require("cookie-session");
|
|
6
|
+
var currentUser = function (req, res, next) {
|
|
7
|
+
var _a;
|
|
8
|
+
if (!((_a = req.session) === null || _a === void 0 ? void 0 : _a.jwt)) {
|
|
9
|
+
return next();
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
var payload = (0, jsonwebtoken_1.verify)(req.session.jwt, process.env.JWT_KEY);
|
|
13
|
+
req.currentUser = payload;
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
}
|
|
17
|
+
next();
|
|
18
|
+
};
|
|
19
|
+
exports.currentUser = currentUser;
|
|
20
|
+
//# sourceMappingURL=current-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middleware/current-user.ts"],"names":[],"mappings":";;;AACA,6CAAsC;AACtC,0BAAwB;AAejB,IAAM,WAAW,GAAG,UAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;;IACvE,IAAI,CAAC,CAAA,MAAA,GAAG,CAAC,OAAO,0CAAE,GAAG,CAAA,EAAE,CAAC;QACpB,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACD,IAAM,OAAO,GAAG,IAAA,qBAAM,EAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,OAAQ,CAAgB,CAAC;QAE7E,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;IACf,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAA;AAbY,QAAA,WAAW,eAavB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,eAAO,MAAM,YAAY,GAAI,KAAK,KAAK,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,uCAUvF,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorHandler = void 0;
|
|
4
|
+
var custom_error_1 = require("../errors/custom-error");
|
|
5
|
+
var errorHandler = function (err, req, res, next) {
|
|
6
|
+
if (err instanceof custom_error_1.CustomError) {
|
|
7
|
+
return res.status(err.statusCode).send({
|
|
8
|
+
errors: err.serializeErrors()
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
res.status(400).send({
|
|
12
|
+
errors: [{ message: 'Something went wrong' }]
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.errorHandler = errorHandler;
|
|
16
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AAE9C,IAAM,YAAY,GAAG,UAAC,GAAU,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB;IACpF,IAAI,GAAG,YAAY,0BAAW,EAAE,CAAC;QAC7B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC;YACnC,MAAM,EAAE,GAAG,CAAC,eAAe,EAAE;SAChC,CAAC,CAAC;IACP,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;KAChD,CAAC,CAAC;AACP,CAAC,CAAA;AAVY,QAAA,YAAY,gBAUxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-auth.d.ts","sourceRoot":"","sources":["../../src/middleware/require-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,eAAO,MAAM,WAAW,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAM1E,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireAuth = void 0;
|
|
4
|
+
var not_authorized_error_1 = require("../errors/not-authorized-error");
|
|
5
|
+
var requireAuth = function (req, res, next) {
|
|
6
|
+
if (!req.currentUser) {
|
|
7
|
+
throw new not_authorized_error_1.NotAuthorizedError();
|
|
8
|
+
}
|
|
9
|
+
next();
|
|
10
|
+
};
|
|
11
|
+
exports.requireAuth = requireAuth;
|
|
12
|
+
//# sourceMappingURL=require-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-auth.js","sourceRoot":"","sources":["../../src/middleware/require-auth.ts"],"names":[],"mappings":";;;AACA,uEAAoE;AAE7D,IAAM,WAAW,GAAG,UAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;IACvE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACnB,MAAM,IAAI,yCAAkB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAA;AANY,QAAA,WAAW,eAMvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-request.d.ts","sourceRoot":"","sources":["../../src/middleware/validation-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAI1D,eAAO,MAAM,eAAe,GAAI,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,SAQ9E,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateRequest = void 0;
|
|
4
|
+
var express_validator_1 = require("express-validator");
|
|
5
|
+
var request_validation_error_1 = require("../errors/request-validation-error");
|
|
6
|
+
var validateRequest = function (req, res, next) {
|
|
7
|
+
var 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;
|
|
14
|
+
//# sourceMappingURL=validation-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation-request.js","sourceRoot":"","sources":["../../src/middleware/validation-request.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AACrD,+EAA4E;AAErE,IAAM,eAAe,GAAG,UAAC,GAAY,EAAE,GAAa,EAAE,IAAkB;IAC3E,IAAM,MAAM,GAAG,IAAA,oCAAgB,EAAC,GAAG,CAAC,CAAC;IAErC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACpB,MAAM,IAAI,iDAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAA;AARY,QAAA,eAAe,mBAQ3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tjticketing/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"main": "./build/index.js",
|
|
5
5
|
"types": "./build/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,5 +18,14 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"del-cli": "^7.0.0",
|
|
20
20
|
"typescript": "^5.9.3"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@types/cookie-session": "^2.0.49",
|
|
24
|
+
"@types/express": "^5.0.6",
|
|
25
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
26
|
+
"cookie-session": "^2.1.1",
|
|
27
|
+
"express": "^5.2.1",
|
|
28
|
+
"express-validator": "^7.3.1",
|
|
29
|
+
"jsonwebtoken": "^9.0.3"
|
|
21
30
|
}
|
|
22
31
|
}
|