@cfticketing/common 1.0.11 → 1.0.13
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 +9 -0
- package/build/errors/bad-request-error.js +18 -0
- package/build/errors/bad-request-error.js.map +1 -0
- package/build/errors/custom-error.d.ts +8 -0
- package/build/errors/custom-error.js +12 -0
- package/build/errors/custom-error.js.map +1 -0
- package/build/errors/database-connection-error.d.ts +9 -0
- package/build/errors/database-connection-error.js +22 -0
- package/build/errors/database-connection-error.js.map +1 -0
- package/build/errors/not-authorized-error.d.ts +8 -0
- package/build/errors/not-authorized-error.js +16 -0
- package/build/errors/not-authorized-error.js.map +1 -0
- package/build/errors/not-found-error.d.ts +8 -0
- package/build/errors/not-found-error.js +21 -0
- package/build/errors/not-found-error.js.map +1 -0
- package/build/errors/request-validation-error.d.ts +14 -0
- package/build/errors/request-validation-error.js +23 -0
- package/build/errors/request-validation-error.js.map +1 -0
- package/build/index.d.ts +10 -0
- package/build/index.js +27 -0
- package/build/index.js.map +1 -0
- package/build/middlewares/current-user.d.ts +14 -0
- package/build/middlewares/current-user.js +27 -0
- package/build/middlewares/current-user.js.map +1 -0
- package/build/middlewares/error-handler.d.ts +2 -0
- package/build/middlewares/error-handler.js +14 -0
- package/build/middlewares/error-handler.js.map +1 -0
- package/build/middlewares/require-auth.d.ts +2 -0
- package/build/middlewares/require-auth.js +13 -0
- package/build/middlewares/require-auth.js.map +1 -0
- package/build/middlewares/validate-request.d.ts +2 -0
- package/build/middlewares/validate-request.js +16 -0
- package/build/middlewares/validate-request.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1,18 @@
|
|
|
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 {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.statusCode = 400;
|
|
10
|
+
// Only because we are extending a built-in class
|
|
11
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
12
|
+
}
|
|
13
|
+
serializeErrors() {
|
|
14
|
+
return [{ message: this.message }];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.BadRequestError = BadRequestError;
|
|
18
|
+
//# 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,uDAAgD;AAEhD,MAAa,eAAgB,SAAQ,6BAAW;IAG9C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAFlC,eAAU,GAAG,GAAG,CAAC;QAKf,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IAED,eAAe;QACb,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AAbD,0CAaC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomError = void 0;
|
|
4
|
+
class CustomError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
// Only because we are extending a built-in class
|
|
8
|
+
Object.setPrototypeOf(this, CustomError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CustomError = CustomError;
|
|
12
|
+
//# 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,MAAsB,WAAY,SAAQ,KAAK;IAE7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;CAGF;AAVD,kCAUC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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 {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("Error connecting to database");
|
|
8
|
+
this.statusCode = 500;
|
|
9
|
+
this.reason = "Error connecting to database";
|
|
10
|
+
// Only because we are extending a built-in class
|
|
11
|
+
Object.setPrototypeOf(this, DatabaseConnectionError.prototype);
|
|
12
|
+
}
|
|
13
|
+
serializeErrors() {
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
message: this.reason,
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.DatabaseConnectionError = DatabaseConnectionError;
|
|
22
|
+
//# 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,uDAAgD;AAEhD,MAAa,uBAAwB,SAAQ,6BAAW;IAGtD;QACE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAHxC,eAAU,GAAG,GAAG,CAAC;QACjB,WAAM,GAAG,8BAA8B,CAAC;QAItC,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;IACD,eAAe;QACb,OAAO;YACL;gBACE,OAAO,EAAE,IAAI,CAAC,MAAM;aACrB;SACF,CAAC;IACJ,CAAC;CACF;AAhBD,0DAgBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 {
|
|
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;
|
|
16
|
+
//# 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,uDAAgD;AAEhD,MAAa,kBAAmB,SAAQ,6BAAW;IAGjD;QACE,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAH1B,eAAU,GAAG,GAAG,CAAC;QAIf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;IAED,eAAe;QACb,OAAO,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACzC,CAAC;CACF;AAXD,gDAWC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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 {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("Route not found");
|
|
8
|
+
this.statusCode = 404;
|
|
9
|
+
// Only because we are extending a built-in class
|
|
10
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
11
|
+
}
|
|
12
|
+
serializeErrors() {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
message: "Not Found",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.NotFoundError = NotFoundError;
|
|
21
|
+
//# 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,uDAAgD;AAEhD,MAAa,aAAc,SAAQ,6BAAW;IAE5C;QACE,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAF3B,eAAU,GAAG,GAAG,CAAC;QAIf,iDAAiD;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACvD,CAAC;IACD,eAAe;QACb,OAAO;YACL;gBACE,OAAO,EAAE,WAAW;aACrB;SACF,CAAC;IACJ,CAAC;CACF;AAfD,sCAeC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomError } from "./custom-error.js";
|
|
2
|
+
import type { ValidationError } from "express-validator";
|
|
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
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 {
|
|
6
|
+
constructor(errors) {
|
|
7
|
+
super("Invalid request parameters");
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
this.statusCode = 400;
|
|
10
|
+
Object.setPrototypeOf(this, RequestValidationError.prototype);
|
|
11
|
+
}
|
|
12
|
+
serializeErrors() {
|
|
13
|
+
return this.errors.map((err) => {
|
|
14
|
+
if (err.type === "field") {
|
|
15
|
+
return { message: err.msg, field: err.path };
|
|
16
|
+
}
|
|
17
|
+
// Generic fallback: for other error types
|
|
18
|
+
return { message: err.msg };
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.RequestValidationError = RequestValidationError;
|
|
23
|
+
//# 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":";;;AAAA,uDAAgD;AAGhD,MAAa,sBAAuB,SAAQ,6BAAW;IAGrD,YAAmB,MAAyB;QAC1C,KAAK,CAAC,4BAA4B,CAAC,CAAC;QADnB,WAAM,GAAN,MAAM,CAAmB;QAF5C,eAAU,GAAG,GAAG,CAAC;QAIf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAChE,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7B,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;gBACzB,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;YAC/C,CAAC;YAED,0CAA0C;YAC1C,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlBD,wDAkBC"}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./errors/not-found-error.js";
|
|
2
|
+
export * from "./errors/bad-request-error.js";
|
|
3
|
+
export * from "./errors/database-connection-error.js";
|
|
4
|
+
export * from "./errors/not-authorized-error.js";
|
|
5
|
+
export * from "./errors/request-validation-error.js";
|
|
6
|
+
export * from "./errors/custom-error.js";
|
|
7
|
+
export * from "./middlewares/current-user.js";
|
|
8
|
+
export * from "./middlewares/error-handler.js";
|
|
9
|
+
export * from "./middlewares/require-auth.js";
|
|
10
|
+
export * from "./middlewares/validate-request.js";
|
package/build/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
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/not-found-error.js"), exports);
|
|
18
|
+
__exportStar(require("./errors/bad-request-error.js"), exports);
|
|
19
|
+
__exportStar(require("./errors/database-connection-error.js"), exports);
|
|
20
|
+
__exportStar(require("./errors/not-authorized-error.js"), exports);
|
|
21
|
+
__exportStar(require("./errors/request-validation-error.js"), exports);
|
|
22
|
+
__exportStar(require("./errors/custom-error.js"), exports);
|
|
23
|
+
__exportStar(require("./middlewares/current-user.js"), exports);
|
|
24
|
+
__exportStar(require("./middlewares/error-handler.js"), exports);
|
|
25
|
+
__exportStar(require("./middlewares/require-auth.js"), exports);
|
|
26
|
+
__exportStar(require("./middlewares/validate-request.js"), exports);
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,gEAA8C;AAC9C,wEAAsD;AACtD,mEAAiD;AACjD,uEAAqD;AACrD,2DAAyC;AAEzC,gEAA8C;AAC9C,iEAA+C;AAC/C,gEAA8C;AAC9C,oEAAkD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Request, Response, NextFunction } from "express";
|
|
2
|
+
interface UserPayload {
|
|
3
|
+
id: string;
|
|
4
|
+
email: string;
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
namespace Express {
|
|
8
|
+
interface Request {
|
|
9
|
+
currentUser?: UserPayload;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare const currentUser: (req: Request, res: Response, next: NextFunction) => void;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
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"));
|
|
8
|
+
// Middleware to extract current user from JWT in session cookie
|
|
9
|
+
const currentUser = (req, res, next) => {
|
|
10
|
+
// If no session or no JWT, skip
|
|
11
|
+
if (!req.session || !req.session.jwt) {
|
|
12
|
+
return next();
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
// Verify JWT using the secret key
|
|
16
|
+
const payload = jsonwebtoken_1.default.verify(req.session.jwt, process.env.JWT_KEY);
|
|
17
|
+
// Attach current user info to request object
|
|
18
|
+
req.currentUser = payload;
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
console.warn("JWT verification failed:", err);
|
|
22
|
+
// Do not block request; just leave currentUser undefined
|
|
23
|
+
}
|
|
24
|
+
next();
|
|
25
|
+
};
|
|
26
|
+
exports.currentUser = currentUser;
|
|
27
|
+
//# sourceMappingURL=current-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-user.js","sourceRoot":"","sources":["../../src/middlewares/current-user.ts"],"names":[],"mappings":";;;;;;AACA,gEAA+B;AAiB/B,gEAAgE;AACzD,MAAM,WAAW,GAAG,CACzB,GAAY,EACZ,GAAa,EACb,IAAkB,EAClB,EAAE;IACF,gCAAgC;IAChC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;QACrC,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,IAAI,CAAC;QACH,kCAAkC;QAClC,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CACxB,GAAG,CAAC,OAAO,CAAC,GAAG,EACf,OAAO,CAAC,GAAG,CAAC,OAAQ,CACN,CAAC;QAEjB,6CAA6C;QAC7C,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAC;QAC9C,yDAAyD;IAC3D,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AAzBW,QAAA,WAAW,eAyBtB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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) {
|
|
7
|
+
return res.status(err.statusCode).send({ errors: err.serializeErrors() });
|
|
8
|
+
}
|
|
9
|
+
res.status(400).send({
|
|
10
|
+
errors: [{ message: err.message || "Something went wrong" }],
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
exports.errorHandler = errorHandler;
|
|
14
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middlewares/error-handler.ts"],"names":[],"mappings":";;;AACA,+DAAwD;AAEjD,MAAM,YAAY,GAAG,CAC1B,GAAU,EACV,GAAY,EACZ,GAAa,EACb,IAAkB,EAClB,EAAE;IACF,IAAI,GAAG,YAAY,6BAAW,EAAE,CAAC;QAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,sBAAsB,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC,CAAC;AAbW,QAAA,YAAY,gBAavB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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) => {
|
|
6
|
+
// User not logged in
|
|
7
|
+
if (!req.currentUser) {
|
|
8
|
+
throw new not_authorized_error_js_1.NotAuthorizedError();
|
|
9
|
+
}
|
|
10
|
+
next();
|
|
11
|
+
};
|
|
12
|
+
exports.requireAuth = requireAuth;
|
|
13
|
+
//# sourceMappingURL=require-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-auth.js","sourceRoot":"","sources":["../../src/middlewares/require-auth.ts"],"names":[],"mappings":";;;AACA,+EAAuE;AAEhE,MAAM,WAAW,GAAG,CACzB,GAAY,EACZ,GAAa,EACb,IAAkB,EAClB,EAAE;IACF,qBAAqB;IACrB,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;QACrB,MAAM,IAAI,4CAAkB,EAAE,CAAC;IACjC,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
// Pull validation errors from express-validator
|
|
8
|
+
const errors = (0, express_validator_1.validationResult)(req);
|
|
9
|
+
// If errors exist, throw custom error
|
|
10
|
+
if (!errors.isEmpty()) {
|
|
11
|
+
throw new request_validation_error_js_1.RequestValidationError(errors.array());
|
|
12
|
+
}
|
|
13
|
+
next();
|
|
14
|
+
};
|
|
15
|
+
exports.validateRequest = validateRequest;
|
|
16
|
+
//# sourceMappingURL=validate-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAC7B,GAAY,EACZ,GAAa,EACb,IAAkB,EAClB,EAAE;IACF,gDAAgD;IAChD,MAAM,MAAM,GAAG,IAAA,oCAAgB,EAAC,GAAG,CAAC,CAAC;IAErC,sCAAsC;IACtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,oDAAsB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,EAAE,CAAC;AACT,CAAC,CAAC;AAdW,QAAA,eAAe,mBAc1B"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfticketing/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "./
|
|
6
|
-
"types": "./
|
|
5
|
+
"main": "./build/index.js",
|
|
6
|
+
"types": "./build/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"
|
|
8
|
+
"build/**/*"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "del-cli build/*",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"typescript": "^5.9.3",
|
|
23
23
|
"del-cli": "^7.0.0",
|
|
24
|
-
"express": "^
|
|
25
|
-
"@types/express": "^
|
|
24
|
+
"express": "^4.21.2",
|
|
25
|
+
"@types/express": "^4.17.25",
|
|
26
26
|
"@types/cookie-session": "^2.0.49",
|
|
27
27
|
"@types/jsonwebtoken": "^9.0.10"
|
|
28
28
|
},
|