@vasrefil/api-toolkit 1.0.50 → 1.0.51

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.
package/dist/env.d.ts CHANGED
@@ -9,6 +9,7 @@ declare const env: {
9
9
  API_KEY: string | undefined;
10
10
  SERVICE_NAME: string | undefined;
11
11
  REDIS_URL: string;
12
+ ERROR_MESSAGE: string;
12
13
  VASREFIL: {
13
14
  BASEURL: string;
14
15
  API_KEY: string | undefined;
package/dist/env.js CHANGED
@@ -15,6 +15,7 @@ const env = {
15
15
  API_KEY: process.env.API_KEY,
16
16
  SERVICE_NAME: process.env.SERVICE_NAME,
17
17
  REDIS_URL: process.env.REDIS_URL,
18
+ ERROR_MESSAGE: 'Sorry an error occured, please try again later',
18
19
  VASREFIL: {
19
20
  BASEURL: NODE_ENV === NODE_ENVS.PROD ? 'https://api.vasrefil.com' : 'https://api-v2-test.vasrefil.com',
20
21
  API_KEY: process.env.VASREFIL_API_KEY
@@ -7,6 +7,7 @@ export declare class RootService {
7
7
  status: Status;
8
8
  message: string;
9
9
  data: any;
10
+ code?: any;
10
11
  };
11
12
  private sanitize_service_resp;
12
13
  private get_response;
@@ -111,12 +111,16 @@ class RootService {
111
111
  };
112
112
  }
113
113
  get_error(error) {
114
- let response = { status: status_interface_1.Status.ERROR, message: 'Request failed', data: null };
115
- const { status, message, data } = error;
114
+ let response = { status: status_interface_1.Status.ERROR, message: env_1.default.ERROR_MESSAGE, data: null, code: null };
115
+ const { status, message, data, code } = error;
116
116
  response.status = status ? status : response.status;
117
+ response.code = code ? code : response.code;
117
118
  if (!(error instanceof mongoose.Error)) {
118
119
  response.message = message ? message : response.message;
119
120
  }
121
+ if (error?.codeName) {
122
+ response.message = env_1.default.ERROR_MESSAGE;
123
+ }
120
124
  response.data = data ? data : response.data;
121
125
  return response;
122
126
  }
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.0.50",
4
+ "version": "1.0.51",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",