@dip-university/common 3.0.30 → 3.0.34
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/index.d.ts +8 -7
- package/build/index.js +1 -0
- package/build/middlewares/currentUser.js +2 -1
- package/package.json +2 -2
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
1
|
+
export * from "./errors/http-error";
|
|
2
|
+
export * from "./errors/request-validation-error";
|
|
3
|
+
export * from "./errors/not-found-error";
|
|
4
|
+
export * from "./errors/database-connection-error";
|
|
5
|
+
export * from "./errors/not-authorized-error";
|
|
6
|
+
export * from "./middlewares/currentUser";
|
|
7
|
+
export * from "./middlewares/requireAuth";
|
|
8
|
+
export * from "./middlewares/error-handler";
|
package/build/index.js
CHANGED
|
@@ -18,6 +18,7 @@ __exportStar(require("./errors/http-error"), exports);
|
|
|
18
18
|
__exportStar(require("./errors/request-validation-error"), exports);
|
|
19
19
|
__exportStar(require("./errors/not-found-error"), exports);
|
|
20
20
|
__exportStar(require("./errors/database-connection-error"), exports);
|
|
21
|
+
__exportStar(require("./errors/not-authorized-error"), exports);
|
|
21
22
|
__exportStar(require("./middlewares/currentUser"), exports);
|
|
22
23
|
__exportStar(require("./middlewares/requireAuth"), exports);
|
|
23
24
|
__exportStar(require("./middlewares/error-handler"), exports);
|
|
@@ -18,11 +18,12 @@ const http_error_1 = require("../errors/http-error");
|
|
|
18
18
|
const currentUser = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
19
|
var _a;
|
|
20
20
|
const token = (_a = req.headers.authorization) === null || _a === void 0 ? void 0 : _a.replace("Bearer ", "");
|
|
21
|
+
console.log("Token:", token);
|
|
21
22
|
if (!token) {
|
|
22
23
|
return next();
|
|
23
24
|
}
|
|
24
25
|
try {
|
|
25
|
-
const decoded = jsonwebtoken_1.default.verify(token, process.env.
|
|
26
|
+
const decoded = jsonwebtoken_1.default.verify(token, process.env.JWT_KEY);
|
|
26
27
|
req.currentUser = { id: decoded.id, email: decoded.email };
|
|
27
28
|
next();
|
|
28
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dip-university/common",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.34",
|
|
4
4
|
"description": "Shared auth, errors, and middleware for microservices",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "del-cli build",
|
|
12
12
|
"build": "npm run clean && tsc",
|
|
13
|
-
"
|
|
13
|
+
"pub": "npm run build && npm version patch && npm publish --access=public"
|
|
14
14
|
},
|
|
15
15
|
"license": "ISC",
|
|
16
16
|
"peerDependencies": {
|