@vasrefil/api-toolkit 1.14.5 → 1.14.6
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.
|
@@ -38,5 +38,8 @@ exports.UserApiResp = {
|
|
|
38
38
|
},
|
|
39
39
|
CRONJOB_NOT_AUTHORIZED: {
|
|
40
40
|
code: 'CRJNA401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Access failed. try again later'
|
|
41
|
+
},
|
|
42
|
+
NO_CRONJOB_TOKEN: {
|
|
43
|
+
code: 'NCRJT401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify cronjob token'
|
|
41
44
|
}
|
|
42
45
|
};
|
|
@@ -14,6 +14,8 @@ class CronjobMidware_ extends _root_service_1.RootService {
|
|
|
14
14
|
return async (req, res, next) => {
|
|
15
15
|
try {
|
|
16
16
|
const cronjob_token = req.headers['x-cronjob-token'];
|
|
17
|
+
if (!cronjob_token)
|
|
18
|
+
throw user_response_1.UserApiResp.NO_AUTHORIZATION_TOKEN;
|
|
17
19
|
if (cronjob_token !== valid_cronjob_token)
|
|
18
20
|
throw user_response_1.UserApiResp.CRONJOB_NOT_AUTHORIZED;
|
|
19
21
|
next();
|
|
@@ -133,6 +133,9 @@ class RootService {
|
|
|
133
133
|
if (message?.includes('authorization header')) {
|
|
134
134
|
response.message = 'Authorization failed.';
|
|
135
135
|
}
|
|
136
|
+
if (message?.includes('cronjob token')) {
|
|
137
|
+
response.message = 'Cronjob authorization failed.';
|
|
138
|
+
}
|
|
136
139
|
if (message?.includes('ETIMEDOUT')) {
|
|
137
140
|
response.message = env_1.default.ERROR_MESSAGE;
|
|
138
141
|
}
|