@vasrefil/api-toolkit 1.3.3 → 1.3.5

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.
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestHelper = void 0;
4
4
  class RequestHelper_ {
5
5
  get_error(error) {
6
- if (error instanceof TypeError) {
7
- return error.message;
6
+ if (error instanceof Error) {
7
+ return error?.stack || error?.message;
8
8
  }
9
9
  else {
10
10
  const url = error?.response?.config?.url || "url";
@@ -116,11 +116,11 @@ class RootService {
116
116
  };
117
117
  }
118
118
  get_error(error) {
119
- console.log('RootService:get_error->error', error);
120
119
  let response = { status: status_interface_1.Status.ERROR, message: env_1.default.ERROR_MESSAGE, data: null, code: null };
121
120
  const { status, message, data, code } = error;
122
121
  response.status = status ? status : response.status;
123
122
  response.code = code ? code : response.code;
123
+ response.data = data ? data : response.data;
124
124
  if (!(error instanceof mongoose.Error)) {
125
125
  response.message = message ? message : response.message;
126
126
  }
@@ -130,13 +130,12 @@ class RootService {
130
130
  if (['invalid signature', 'jwt expired'].includes(response.message)) {
131
131
  response.message = 'Authentication failed. Please log in again.';
132
132
  }
133
- if (message.includes('authorization header')) {
133
+ if (message?.includes('authorization header')) {
134
134
  response.message = 'Authorization failed.';
135
135
  }
136
- if (message.includes('ETIMEDOUT')) {
136
+ if (message?.includes('ETIMEDOUT')) {
137
137
  response.message = env_1.default.ERROR_MESSAGE;
138
138
  }
139
- response.data = data ? data : response.data;
140
139
  return response;
141
140
  }
142
141
  getHttpStatus(status) {
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.3.3",
4
+ "version": "1.3.5",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",