@vasrefil/api-toolkit 1.0.50 → 1.0.52

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
@@ -5,10 +5,11 @@ declare enum NODE_ENVS {
5
5
  }
6
6
  declare const env: {
7
7
  NODE_ENV: NODE_ENVS;
8
- MONGODB_URI: string;
8
+ MONGODB_URI: string | undefined;
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
@@ -11,10 +11,11 @@ var NODE_ENVS;
11
11
  let NODE_ENV = process.env.NODE_ENV;
12
12
  const env = {
13
13
  NODE_ENV,
14
- MONGODB_URI: '',
14
+ MONGODB_URI: process.env.MONGODB_URI,
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
@@ -25,6 +25,14 @@ class QueryHelper_ {
25
25
  else if (fit.operator === 'is_not') {
26
26
  result.push({ [fit.field]: { $ne: fit.value } });
27
27
  }
28
+ else if (fit.operator === 'gte') {
29
+ const value = isNaN(fit.value) ? fit.value : Number(fit.value);
30
+ result.push({ [fit.field]: { $gte: value } });
31
+ }
32
+ else if (fit.operator === 'lte') {
33
+ const value = isNaN(fit.value) ? fit.value : Number(fit.value);
34
+ result.push({ [fit.field]: { $lte: value } });
35
+ }
28
36
  });
29
37
  filter_query = { [logical_operator]: result };
30
38
  }
@@ -2,6 +2,7 @@ import { Document, Model } from "mongoose";
2
2
  export interface ISample extends Document {
3
3
  name: string;
4
4
  description?: string;
5
+ number?: number;
5
6
  }
6
7
  export interface ISampleModel extends Model<ISample> {
7
8
  }
@@ -8,6 +8,9 @@ const schema = new mongoose_1.Schema({
8
8
  description: {
9
9
  type: String
10
10
  },
11
+ number: {
12
+ type: Number
13
+ },
11
14
  }, { timestamps: true });
12
15
  schema.index({});
13
16
  const SampleModel = (0, mongoose_1.model)('sample', schema);
@@ -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
  }
@@ -38,7 +38,8 @@ class SampleValidator {
38
38
  constructor() {
39
39
  this.create = joi.object({
40
40
  name: joi.string().required(),
41
- description: joi.string().required()
41
+ description: joi.string().required(),
42
+ number: joi.number().required(),
42
43
  });
43
44
  }
44
45
  }
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.52",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",