@vasrefil/api-toolkit 1.0.39 → 1.0.40
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.
|
@@ -9,6 +9,9 @@ exports.UserApiResp = {
|
|
|
9
9
|
NOT_AUTHORIZED: {
|
|
10
10
|
code: 'NA00401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'You are not authorized'
|
|
11
11
|
},
|
|
12
|
+
NO_API_KEY: {
|
|
13
|
+
code: 'NAPK0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify api key'
|
|
14
|
+
},
|
|
12
15
|
USER_NOT_FOUND: {
|
|
13
16
|
code: 'UNF0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'User not found'
|
|
14
17
|
},
|
|
@@ -18,7 +18,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
|
|
|
18
18
|
const apiKey = req.headers['api-key'];
|
|
19
19
|
if (apiKey) {
|
|
20
20
|
if (apiKey !== env_1.default.VASREFIL.API_KEY)
|
|
21
|
-
throw user_response_1.UserApiResp.
|
|
21
|
+
throw user_response_1.UserApiResp.NO_API_KEY;
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
const { admin_user } = await this.get_admin(req);
|
|
@@ -37,7 +37,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
|
|
|
37
37
|
const apiKey = req.headers['api-key'];
|
|
38
38
|
if (apiKey) {
|
|
39
39
|
if (apiKey !== env_1.default.VAS_VOUCHER.API_KEY)
|
|
40
|
-
throw user_response_1.UserApiResp.
|
|
40
|
+
throw user_response_1.UserApiResp.NO_API_KEY;
|
|
41
41
|
}
|
|
42
42
|
else {
|
|
43
43
|
const { admin_user } = await this.get_admin(req);
|
|
@@ -56,7 +56,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
|
|
|
56
56
|
const apiKey = req.headers['api-key'];
|
|
57
57
|
if (apiKey) {
|
|
58
58
|
if (apiKey !== env_1.default.EDUCATION.API_KEY)
|
|
59
|
-
throw user_response_1.UserApiResp.
|
|
59
|
+
throw user_response_1.UserApiResp.NO_API_KEY;
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
62
|
const { admin_user } = await this.get_admin(req);
|
|
@@ -76,6 +76,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
|
|
|
76
76
|
delete req.headers['content-length'];
|
|
77
77
|
const headers = {
|
|
78
78
|
Authorization: req.headers.authorization,
|
|
79
|
+
'x-service-name': env_1.default.SERVICE_NAME,
|
|
79
80
|
};
|
|
80
81
|
const { data } = await axios_1.default.get(`${baseurl}/admin-users/details`, { headers });
|
|
81
82
|
return { admin_user: data.data.user };
|
|
@@ -20,8 +20,8 @@ class LogUtil_ {
|
|
|
20
20
|
const payload = {
|
|
21
21
|
distinct_id: user.distinct_id,
|
|
22
22
|
service_name: env_1.default.SERVICE_NAME,
|
|
23
|
-
request:
|
|
24
|
-
response:
|
|
23
|
+
request: json_stringify_safe(request, null),
|
|
24
|
+
response: json_stringify_safe(response, null),
|
|
25
25
|
request_url: request?.url,
|
|
26
26
|
event: actionType,
|
|
27
27
|
type: 'USER_EVENT',
|
|
@@ -32,7 +32,7 @@ class LogUtil_ {
|
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
34
|
airbrake_1.airbrake.notify({
|
|
35
|
-
error:
|
|
35
|
+
error: json_stringify_safe(error, null),
|
|
36
36
|
context: { component: 'USER_EVENT' },
|
|
37
37
|
params: { actionType, status, request },
|
|
38
38
|
});
|