@prepskill/common 1.0.7 → 1.0.10
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/BadRequestError.d.ts +4 -0
- package/dist/errors/BadRequestError.js +10 -0
- package/dist/errors/NotFoundError.d.ts +4 -0
- package/dist/errors/NotFoundError.js +10 -0
- package/dist/errors/UnauthorizedError.d.ts +4 -0
- package/dist/errors/UnauthorizedError.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/middlewares/errorHandler.js +1 -1
- package/dist/middlewares/protect.js +2 -2
- package/package.json +4 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BadRequestError = void 0;
|
|
4
|
+
const AppError_1 = require("./AppError");
|
|
5
|
+
class BadRequestError extends AppError_1.AppError {
|
|
6
|
+
constructor(message = 'Bad Request') {
|
|
7
|
+
super(message, 400);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.BadRequestError = BadRequestError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NotFoundError = void 0;
|
|
4
|
+
const AppError_1 = require("./AppError");
|
|
5
|
+
class NotFoundError extends AppError_1.AppError {
|
|
6
|
+
constructor(message = "Not Found") {
|
|
7
|
+
super(message, 404);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.NotFoundError = NotFoundError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnauthorizedError = void 0;
|
|
4
|
+
const AppError_1 = require("./AppError");
|
|
5
|
+
class UnauthorizedError extends AppError_1.AppError {
|
|
6
|
+
constructor(message = 'Unauthorized') {
|
|
7
|
+
super(message, 401);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UnauthorizedError = UnauthorizedError;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,3 +3,6 @@ export * from "./errors/AppError";
|
|
|
3
3
|
export * from "./middlewares/asyncHandler";
|
|
4
4
|
export * from "./middlewares/errorHandler";
|
|
5
5
|
export * from "./middlewares/protect";
|
|
6
|
+
export * from './errors/BadRequestError';
|
|
7
|
+
export * from './errors/NotFoundError';
|
|
8
|
+
export * from './errors/UnauthorizedError';
|
package/dist/index.js
CHANGED
|
@@ -19,3 +19,6 @@ __exportStar(require("./errors/AppError"), exports);
|
|
|
19
19
|
__exportStar(require("./middlewares/asyncHandler"), exports);
|
|
20
20
|
__exportStar(require("./middlewares/errorHandler"), exports);
|
|
21
21
|
__exportStar(require("./middlewares/protect"), exports);
|
|
22
|
+
__exportStar(require("./errors/BadRequestError"), exports);
|
|
23
|
+
__exportStar(require("./errors/NotFoundError"), exports);
|
|
24
|
+
__exportStar(require("./errors/UnauthorizedError"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
|
-
const AppError_1 = require("
|
|
4
|
+
const AppError_1 = require("../../dist/errors/AppError");
|
|
5
5
|
const errorHandler = (err, req, res, next) => {
|
|
6
6
|
if (err instanceof AppError_1.AppError) {
|
|
7
7
|
return res.status(err.statusCode).json({
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.protect = void 0;
|
|
7
7
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const AppError_1 = require("
|
|
8
|
+
const AppError_1 = require("../../dist/errors/AppError");
|
|
9
9
|
const protect = (secret) => {
|
|
10
10
|
return (req, res, next) => {
|
|
11
11
|
const authHeader = req.headers.authorization;
|
|
@@ -18,7 +18,7 @@ const protect = (secret) => {
|
|
|
18
18
|
req.user = decoded;
|
|
19
19
|
next();
|
|
20
20
|
}
|
|
21
|
-
catch
|
|
21
|
+
catch {
|
|
22
22
|
throw new AppError_1.AppError("Invalid token", 401);
|
|
23
23
|
}
|
|
24
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prepskill/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "Common utilities, errors and middlewares for Prepskill microservices",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "tsc"
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"pub": "git init && git add . && git commit -m 'chore: publish common package' && npm version patch && npm publish --access public"
|
|
12
13
|
},
|
|
13
14
|
"publishConfig": {
|
|
14
15
|
"access": "public"
|
|
@@ -18,6 +19,7 @@
|
|
|
18
19
|
"license": "ISC",
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"express": "^5.2.1",
|
|
22
|
+
"ioredis": "^5.10.0",
|
|
21
23
|
"jsonwebtoken": "^9.0.3"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|