@lucaapp/service-utils 1.55.11 → 1.55.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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as jose from 'jose';
|
|
2
2
|
import { HttpMethod } from 'types/http';
|
|
3
3
|
import { Request, RequestHandler } from 'express';
|
|
4
|
+
import { ResponseType } from 'axios';
|
|
4
5
|
import { Service } from './service';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
type JWKS = {
|
|
@@ -30,7 +31,7 @@ declare class ServiceIdentity {
|
|
|
30
31
|
private getJwtVerifyOptions;
|
|
31
32
|
getIdentityPublicKey: () => Promise<jose.KeyLike>;
|
|
32
33
|
getIdentityPrivateKey: () => Promise<jose.KeyLike>;
|
|
33
|
-
callService: <T>(service: Service, method: HttpMethod, url: string, data?: unknown) => Promise<T>;
|
|
34
|
+
callService: <T>(service: Service, method: HttpMethod, url: string, data?: unknown, responseType?: ResponseType, customHeaders?: Record<string, string>) => Promise<T>;
|
|
34
35
|
signJWT: (service: string, method: HttpMethod, url: string, data?: unknown) => Promise<string>;
|
|
35
36
|
verifyJWT: (request: Request, service: string) => Promise<{
|
|
36
37
|
payload: jose.JWTPayload;
|
|
@@ -85,16 +85,18 @@ class ServiceIdentity {
|
|
|
85
85
|
}
|
|
86
86
|
return this.keyCache.private;
|
|
87
87
|
};
|
|
88
|
-
this.callService = async (service, method, url, data) => {
|
|
88
|
+
this.callService = async (service, method, url, data, responseType, customHeaders) => {
|
|
89
89
|
const jwt = await this.signJWT(service, method, url, data);
|
|
90
90
|
const request = {
|
|
91
91
|
headers: {
|
|
92
92
|
[JWT_HEADER_NAME]: jwt,
|
|
93
93
|
...(0, requestTracer_1.getRequestIdHeader)(),
|
|
94
|
+
...customHeaders,
|
|
94
95
|
},
|
|
95
96
|
baseURL: `http://${service}:8080/`,
|
|
96
97
|
url,
|
|
97
98
|
method,
|
|
99
|
+
responseType,
|
|
98
100
|
};
|
|
99
101
|
const response = await this.axiosClient.request(request);
|
|
100
102
|
return response.data;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucaapp/service-utils",
|
|
3
|
-
"version": "1.55.
|
|
3
|
+
"version": "1.55.13",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"@asteasolutions/zod-to-openapi": "6.1.0",
|
|
22
22
|
"@hapi/boom": "^10.0.0",
|
|
23
23
|
"@tsconfig/node18": "1.0.1",
|
|
24
|
-
"@types/express": "4.17.
|
|
25
|
-
"@types/express-serve-static-core": "4.17.43",
|
|
24
|
+
"@types/express": "4.17.15",
|
|
25
|
+
"@types/express-serve-static-core": "^4.17.43",
|
|
26
26
|
"@types/node": "18.18.2",
|
|
27
27
|
"@types/response-time": "^2.3.5",
|
|
28
28
|
"@types/swagger-ui-express": "4.1.3",
|
|
29
29
|
"axios": "^1.6.0",
|
|
30
30
|
"cls-rtracer": "^2.6.2",
|
|
31
|
-
"express": "4.
|
|
31
|
+
"express": "4.17.3",
|
|
32
32
|
"express-async-errors": "3.1.1",
|
|
33
33
|
"jose": "4.15.5",
|
|
34
34
|
"kafkajs": "2.1.0",
|
|
@@ -47,8 +47,6 @@
|
|
|
47
47
|
"zod": "3.22.3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@types/express": "4.17.21",
|
|
51
|
-
"@types/express-serve-static-core": "4.17.43",
|
|
52
50
|
"@types/lodash": "^4.14.187",
|
|
53
51
|
"@types/negotiator": "^0.6.1",
|
|
54
52
|
"@types/pino-http": "5.8.4",
|
|
@@ -59,7 +57,7 @@
|
|
|
59
57
|
"@vitest/coverage-v8": "0.32.0",
|
|
60
58
|
"@vitest/ui": "0.32.0",
|
|
61
59
|
"conventional-changelog-conventionalcommits": "^5.0.0",
|
|
62
|
-
"eslint": "
|
|
60
|
+
"eslint": "8.57.0",
|
|
63
61
|
"eslint-plugin-prettier": "4.2.1",
|
|
64
62
|
"eslint-plugin-vitest": "0.0.54",
|
|
65
63
|
"improved-yarn-audit": "^3.0.0",
|