@vasrefil/api-toolkit 1.14.5 → 1.14.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.
@@ -60,4 +60,9 @@ export declare const UserApiResp: {
60
60
  status: Status;
61
61
  message: string;
62
62
  };
63
+ NO_CRONJOB_TOKEN: {
64
+ code: string;
65
+ status: Status;
66
+ message: string;
67
+ };
63
68
  };
@@ -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_CRONJOB_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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.14.5",
4
+ "version": "1.14.7",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",