@mjybtickets/common 1.0.6 → 1.0.8
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 +6 -2
- package/build/errors/bad-request-error.js.map +1 -1
- package/build/errors/custom-error.js +5 -1
- package/build/errors/custom-error.js.map +1 -1
- package/build/errors/database-connection-error.js +6 -2
- package/build/errors/database-connection-error.js.map +1 -1
- package/build/errors/not-authorized-error.js +6 -2
- package/build/errors/not-authorized-error.js.map +1 -1
- package/build/errors/not-found-error.js +7 -3
- package/build/errors/not-found-error.js.map +1 -1
- package/build/errors/request-validation-error.js +6 -2
- package/build/errors/request-validation-error.js.map +1 -1
- package/build/index.js +26 -10
- package/build/index.js.map +1 -1
- package/build/middlewares/current-user.js +10 -3
- package/build/middlewares/current-user.js.map +1 -1
- package/build/middlewares/error-handler.d.ts.map +1 -1
- package/build/middlewares/error-handler.js +8 -3
- package/build/middlewares/error-handler.js.map +1 -1
- package/build/middlewares/require-auth.js +7 -3
- package/build/middlewares/require-auth.js.map +1 -1
- package/build/middlewares/validate-request.js +9 -5
- package/build/middlewares/validate-request.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BadRequestError = void 0;
|
|
4
|
+
const custom_error_js_1 = require("./custom-error.js");
|
|
5
|
+
class BadRequestError extends custom_error_js_1.CustomError {
|
|
3
6
|
message;
|
|
4
7
|
statusCode = 400;
|
|
5
8
|
constructor(message) {
|
|
@@ -12,4 +15,5 @@ export class BadRequestError extends CustomError {
|
|
|
12
15
|
return [{ message: this.message }];
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
exports.BadRequestError = BadRequestError;
|
|
15
19
|
//# sourceMappingURL=bad-request-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"bad-request-error.js","sourceRoot":"","sources":["../../src/errors/bad-request-error.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,MAAa,eAAgB,SAAQ,6BAAW;IAGzB;IAFnB,UAAU,GAAG,GAAG,CAAC;IAEjB,YAAmB,OAAe;QAC9B,KAAK,CAAC,OAAO,CAAC,CAAC;QADA,YAAO,GAAP,OAAO,CAAQ;QAG9B,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED,eAAe;QACX,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;CACJ;AAbD,0CAaC"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomError = void 0;
|
|
4
|
+
class CustomError extends Error {
|
|
2
5
|
constructor(message) {
|
|
3
6
|
super(message);
|
|
4
7
|
// Only because we are extending a built-in class
|
|
5
8
|
Object.setPrototypeOf(this, CustomError.prototype);
|
|
6
9
|
}
|
|
7
10
|
}
|
|
11
|
+
exports.CustomError = CustomError;
|
|
8
12
|
//# sourceMappingURL=custom-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"custom-error.js","sourceRoot":"","sources":["../../src/errors/custom-error.ts"],"names":[],"mappings":";;;AAAA,MAAsB,WAAY,SAAQ,KAAK;IAG3C,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;CAMJ;AAdD,kCAcC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseConnectionError = void 0;
|
|
4
|
+
const custom_error_js_1 = require("./custom-error.js");
|
|
5
|
+
class DatabaseConnectionError extends custom_error_js_1.CustomError {
|
|
3
6
|
statusCode = 500;
|
|
4
7
|
reason = 'Error connecting to database';
|
|
5
8
|
constructor() {
|
|
@@ -11,4 +14,5 @@ export class DatabaseConnectionError extends CustomError {
|
|
|
11
14
|
return [{ message: this.reason }];
|
|
12
15
|
}
|
|
13
16
|
}
|
|
17
|
+
exports.DatabaseConnectionError = DatabaseConnectionError;
|
|
14
18
|
//# sourceMappingURL=database-connection-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database-connection-error.js","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"database-connection-error.js","sourceRoot":"","sources":["../../src/errors/database-connection-error.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,MAAa,uBAAwB,SAAQ,6BAAW;IACpD,UAAU,GAAG,GAAG,CAAC;IACjB,MAAM,GAAG,8BAA8B,CAAC;IAExC;QACI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAEtC,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;IAED,eAAe;QACX,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACtC,CAAC;CACJ;AAdD,0DAcC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotAuthorizedError = void 0;
|
|
4
|
+
const custom_error_js_1 = require("./custom-error.js");
|
|
5
|
+
class NotAuthorizedError extends custom_error_js_1.CustomError {
|
|
3
6
|
statusCode = 401;
|
|
4
7
|
constructor() {
|
|
5
8
|
super('Not authorized');
|
|
@@ -10,4 +13,5 @@ export class NotAuthorizedError extends CustomError {
|
|
|
10
13
|
return [{ message: 'Not authorized' }];
|
|
11
14
|
}
|
|
12
15
|
}
|
|
16
|
+
exports.NotAuthorizedError = NotAuthorizedError;
|
|
13
17
|
//# sourceMappingURL=not-authorized-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-authorized-error.js","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"not-authorized-error.js","sourceRoot":"","sources":["../../src/errors/not-authorized-error.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,MAAa,kBAAmB,SAAQ,6BAAW;IAC/C,UAAU,GAAG,GAAG,CAAC;IAEjB;QACI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAExB,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;IAED,eAAe;QACX,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAC3C,CAAC;CACJ;AAbD,gDAaC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotFoundError = void 0;
|
|
4
|
+
const custom_error_js_1 = require("./custom-error.js");
|
|
5
|
+
class NotFoundError extends custom_error_js_1.CustomError {
|
|
3
6
|
statusCode = 404;
|
|
4
7
|
constructor() {
|
|
5
8
|
super('Route not found');
|
|
6
9
|
// Only because we are extending a built-in class
|
|
7
|
-
Object.setPrototypeOf(this, CustomError.prototype);
|
|
10
|
+
Object.setPrototypeOf(this, custom_error_js_1.CustomError.prototype);
|
|
8
11
|
}
|
|
9
12
|
serializeErrors = () => {
|
|
10
13
|
return [{ message: 'Not Found' }];
|
|
11
14
|
};
|
|
12
15
|
}
|
|
16
|
+
exports.NotFoundError = NotFoundError;
|
|
13
17
|
//# sourceMappingURL=not-found-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"not-found-error.js","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"not-found-error.js","sourceRoot":"","sources":["../../src/errors/not-found-error.ts"],"names":[],"mappings":";;;AAAA,uDAAgD;AAEhD,MAAa,aAAc,SAAQ,6BAAW;IAC1C,UAAU,GAAG,GAAG,CAAC;IAEjB;QACI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAEzB,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,6BAAW,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IAED,eAAe,GAAG,GAAG,EAAE;QACnB,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC;IACtC,CAAC,CAAA;CACJ;AAbD,sCAaC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequestValidationError = void 0;
|
|
4
|
+
const custom_error_js_1 = require("./custom-error.js");
|
|
5
|
+
class RequestValidationError extends custom_error_js_1.CustomError {
|
|
3
6
|
errors;
|
|
4
7
|
statusCode = 400;
|
|
5
8
|
constructor(errors) {
|
|
@@ -17,4 +20,5 @@ export class RequestValidationError extends CustomError {
|
|
|
17
20
|
});
|
|
18
21
|
}
|
|
19
22
|
}
|
|
23
|
+
exports.RequestValidationError = RequestValidationError;
|
|
20
24
|
//# sourceMappingURL=request-validation-error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-validation-error.js","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"request-validation-error.js","sourceRoot":"","sources":["../../src/errors/request-validation-error.ts"],"names":[],"mappings":";;;AACA,uDAAgD;AAEhD,MAAa,sBAAuB,SAAQ,6BAAW;IAGhC;IAFnB,UAAU,GAAG,GAAG,CAAC;IAEjB,YAAmB,MAAyB;QACxC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QADrB,WAAM,GAAN,MAAM,CAAmB;QAGxC,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC3B,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACvB,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;YACjD,CAAC;YACD,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAChC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAlBD,wDAkBC"}
|
package/build/index.js
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Re-export stuff from errors and middlewares
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./errors/bad-request-error.js"), exports);
|
|
19
|
+
__exportStar(require("./errors/custom-error.js"), exports);
|
|
20
|
+
__exportStar(require("./errors/database-connection-error.js"), exports);
|
|
21
|
+
__exportStar(require("./errors/not-authorized-error.js"), exports);
|
|
22
|
+
__exportStar(require("./errors/not-found-error.js"), exports);
|
|
23
|
+
__exportStar(require("./errors/request-validation-error.js"), exports);
|
|
24
|
+
__exportStar(require("./middlewares/current-user.js"), exports);
|
|
25
|
+
__exportStar(require("./middlewares/error-handler.js"), exports);
|
|
26
|
+
__exportStar(require("./middlewares/require-auth.js"), exports);
|
|
27
|
+
__exportStar(require("./middlewares/validate-request.js"), exports);
|
|
12
28
|
//# 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":"AAAA,8CAA8C
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,8CAA8C;;;;;;;;;;;;;;;;AAE9C,gEAA8C;AAC9C,2DAAyC;AACzC,wEAAsD;AACtD,mEAAiD;AACjD,8DAA4C;AAC5C,uEAAqD;AAErD,gEAA8C;AAC9C,iEAA+C;AAC/C,gEAA8C;AAC9C,oEAAkD"}
|
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.currentUser = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
2
8
|
;
|
|
3
|
-
|
|
9
|
+
const currentUser = (req, res, next) => {
|
|
4
10
|
if (!req.session?.jwt) {
|
|
5
11
|
return next();
|
|
6
12
|
}
|
|
7
13
|
try {
|
|
8
|
-
const payload =
|
|
14
|
+
const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
9
15
|
req.currentUser = payload;
|
|
10
16
|
}
|
|
11
17
|
catch (err) { }
|
|
12
18
|
next();
|
|
13
19
|
};
|
|
20
|
+
exports.currentUser = currentUser;
|
|
14
21
|
//# sourceMappingURL=current-user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":";;;;;;AACA,gEAA+B;AAK9B,CAAC;AAaK,MAAM,WAAW,GAAG,CACvB,GAAY,EACZ,GAAa,EACb,IAAkB,EACpB,EAAE;IACA,IAAG,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,EAAC,CAAC;QAClB,OAAO,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,IAAG,CAAC;QACA,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CACtB,GAAG,CAAC,OAAO,CAAC,GAAG,EACf,OAAO,CAAC,GAAG,CAAC,OAAQ,CACR,CAAC;QAEjB,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC;IAC9B,CAAC;IAAC,OAAO,GAAG,EAAC,CAAC,CAAA,CAAC;IAEf,IAAI,EAAE,CAAC;AACX,CAAC,CAAA;AAnBY,QAAA,WAAW,eAmBvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,eAAO,MAAM,YAAY,GACrB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D,eAAO,MAAM,YAAY,GACrB,KAAK,KAAK,EACV,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,MAAM,YAAY,mDAUrB,CAAA"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.errorHandler = void 0;
|
|
4
|
+
const custom_error_js_1 = require("../errors/custom-error.js");
|
|
5
|
+
const errorHandler = (err, req, res, next) => {
|
|
6
|
+
if (err instanceof custom_error_js_1.CustomError) {
|
|
4
7
|
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
5
8
|
}
|
|
9
|
+
console.error(err);
|
|
6
10
|
res.status(400).send({
|
|
7
11
|
errors: [{ message: 'Something went wrong' }]
|
|
8
12
|
});
|
|
9
13
|
};
|
|
14
|
+
exports.errorHandler = errorHandler;
|
|
10
15
|
//# sourceMappingURL=error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":";;;AACA,+DAAwD;AAEjD,MAAM,YAAY,GAAG,CACxB,GAAU,EACV,GAAY,EACZ,GAAa,EACb,IAAkB,EACpB,EAAE;IACA,IAAG,GAAG,YAAY,6BAAW,EAAC,CAAC;QAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACjB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,sBAAsB,EAAC,CAAC;KAC/C,CAAC,CAAC;AACP,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireAuth = void 0;
|
|
4
|
+
const not_authorized_error_js_1 = require("../errors/not-authorized-error.js");
|
|
5
|
+
const requireAuth = (req, res, next) => {
|
|
3
6
|
if (!req.currentUser) {
|
|
4
|
-
throw new NotAuthorizedError();
|
|
7
|
+
throw new not_authorized_error_js_1.NotAuthorizedError();
|
|
5
8
|
}
|
|
6
9
|
next();
|
|
7
10
|
};
|
|
11
|
+
exports.requireAuth = requireAuth;
|
|
8
12
|
//# sourceMappingURL=require-auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-auth.js","sourceRoot":"","sources":["../../src/middlewares/require-auth.ts"],"names":[],"mappings":"AACA
|
|
1
|
+
{"version":3,"file":"require-auth.js","sourceRoot":"","sources":["../../src/middlewares/require-auth.ts"],"names":[],"mappings":";;;AACA,+EAAuE;AAEhE,MAAM,WAAW,GAAG,CACvB,GAAY,EACZ,GAAa,EACb,IAAkB,EACpB,EAAE;IACA,IAAG,CAAC,GAAG,CAAC,WAAW,EAAC,CAAC;QACjB,MAAM,IAAI,4CAAkB,EAAE,CAAC;IACnC,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAA;AAVY,QAAA,WAAW,eAUvB"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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_js_1 = require("../errors/request-validation-error.js");
|
|
6
|
+
const validateRequest = (req, res, next) => {
|
|
7
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
5
8
|
if (!errors.isEmpty()) {
|
|
6
|
-
throw new RequestValidationError(errors.array());
|
|
9
|
+
throw new request_validation_error_js_1.RequestValidationError(errors.array());
|
|
7
10
|
}
|
|
8
11
|
next();
|
|
9
12
|
};
|
|
13
|
+
exports.validateRequest = validateRequest;
|
|
10
14
|
//# sourceMappingURL=validate-request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-request.js","sourceRoot":"","sources":["../../src/middlewares/validate-request.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"validate-request.js","sourceRoot":"","sources":["../../src/middlewares/validate-request.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AACrD,uFAA+E;AAExE,MAAM,eAAe,GAAG,CAC3B,GAAY,EACZ,GAAa,EACb,IAAkB,EACpB,EAAE;IACA,MAAM,MAAM,GAAG,IAAA,oCAAgB,EAAC,GAAG,CAAC,CAAC;IAErC,IAAG,CAAC,MAAM,CAAC,OAAO,EAAE,EAAC,CAAC;QAClB,MAAM,IAAI,oDAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,EAAE,CAAC;AACX,CAAC,CAAC;AAZW,QAAA,eAAe,mBAY1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mjybtickets/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"keywords": [],
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
|
-
"
|
|
18
|
+
"module": "commonjs",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"del-cli": "^7.0.0",
|
|
21
21
|
"typescript": "^6.0.2"
|