@vasrefil/api-toolkit 1.2.6 → 1.2.7
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.
|
@@ -126,6 +126,15 @@ class RootService {
|
|
|
126
126
|
if (error?.codeName) {
|
|
127
127
|
response.message = env_1.default.ERROR_MESSAGE;
|
|
128
128
|
}
|
|
129
|
+
if (['invalid signature', 'jwt expired'].includes(response.message)) {
|
|
130
|
+
response.message = 'Authentication failed. Please log in again.';
|
|
131
|
+
}
|
|
132
|
+
if (message.includes('authorization header')) {
|
|
133
|
+
response.message = 'Authorization failed.';
|
|
134
|
+
}
|
|
135
|
+
if (message.includes('ETIMEDOUT')) {
|
|
136
|
+
response.message = env_1.default.ERROR_MESSAGE;
|
|
137
|
+
}
|
|
129
138
|
response.data = data ? data : response.data;
|
|
130
139
|
return response;
|
|
131
140
|
}
|
|
@@ -76,7 +76,12 @@ declare class LogUtil_ {
|
|
|
76
76
|
};
|
|
77
77
|
method: string;
|
|
78
78
|
url: string;
|
|
79
|
+
host: string;
|
|
80
|
+
hostname: string;
|
|
79
81
|
statusCode: number | undefined;
|
|
82
|
+
originalUrl: string;
|
|
83
|
+
baseUrl: string;
|
|
84
|
+
ip: string | undefined;
|
|
80
85
|
body: any;
|
|
81
86
|
};
|
|
82
87
|
private get_user_event_response;
|
|
@@ -59,10 +59,21 @@ class LogUtil_ {
|
|
|
59
59
|
this.get_request = (req) => {
|
|
60
60
|
const { authorization, pin_token, ...headers_ } = req.headers;
|
|
61
61
|
const { password, pin, old_pin, new_pin, bvn, nin, file, ...body_ } = req.body;
|
|
62
|
-
const { params, query, method, url, statusCode } = req;
|
|
62
|
+
const { params, query, method, url, statusCode, host, hostname, originalUrl, baseUrl } = req;
|
|
63
63
|
delete headers_['pin-token'];
|
|
64
|
+
const ip = req.headers["x-forwarded-for"]?.split(",")[0]?.trim() || req.socket.remoteAddress;
|
|
64
65
|
const request = {
|
|
65
|
-
params,
|
|
66
|
+
params,
|
|
67
|
+
query,
|
|
68
|
+
headers: headers_,
|
|
69
|
+
method,
|
|
70
|
+
url,
|
|
71
|
+
host,
|
|
72
|
+
hostname,
|
|
73
|
+
statusCode,
|
|
74
|
+
originalUrl,
|
|
75
|
+
baseUrl,
|
|
76
|
+
ip,
|
|
66
77
|
body: body_,
|
|
67
78
|
};
|
|
68
79
|
return request;
|