@vasrefil/api-toolkit 1.0.10 → 1.0.12

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
@@ -1,12 +1,20 @@
1
+ import { EnvsI } from "./interfaces/env.interface";
2
+ declare enum NODE_ENVS {
3
+ DEV = "dev",
4
+ PROD = "prod",
5
+ LOCAL = "local"
6
+ }
1
7
  declare const env: {
2
- MONGODB_URI: string | undefined;
3
- ADMIN_JWT_KEY: string;
4
- NODE_ENV: string | undefined;
5
- RATE_LIMIT_REDIS_URL: string | undefined;
6
- API_KEY: string | undefined;
8
+ NODE_ENV: NODE_ENVS;
9
+ MONGODB_URI: string;
10
+ VASREFIL: {
11
+ BASEURL: string;
12
+ API_KEY: string | undefined;
13
+ };
7
14
  AIRBRAKE: {
8
15
  PROJECT_ID: string | undefined;
9
16
  PROJECT_KEY: string | undefined;
10
17
  };
11
18
  };
19
+ export declare const setEnvs: (payload: EnvsI) => void;
12
20
  export default env;
package/dist/env.js CHANGED
@@ -1,16 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const dotenv = require('dotenv');
4
- dotenv.config();
3
+ exports.setEnvs = void 0;
4
+ var NODE_ENVS;
5
+ (function (NODE_ENVS) {
6
+ NODE_ENVS["DEV"] = "dev";
7
+ NODE_ENVS["PROD"] = "prod";
8
+ NODE_ENVS["LOCAL"] = "local";
9
+ })(NODE_ENVS || (NODE_ENVS = {}));
10
+ let NODE_ENV = '';
5
11
  const env = {
6
- MONGODB_URI: process.env.MONGODB_URI,
7
- ADMIN_JWT_KEY: process.env.ADMIN_JWT_KEY,
8
- NODE_ENV: process.env.NODE_ENV,
9
- RATE_LIMIT_REDIS_URL: process.env.RATE_LIMIT_REDIS_URL,
10
- API_KEY: process.env.API_KEY,
12
+ NODE_ENV,
13
+ MONGODB_URI: '',
14
+ VASREFIL: {
15
+ BASEURL: NODE_ENV === NODE_ENVS.PROD ? 'https://api.vasrefil.com' : 'https://api-v2-test.vasrefil.com',
16
+ API_KEY: process.env.VASREFIL_API_KEY
17
+ },
11
18
  AIRBRAKE: {
12
19
  PROJECT_ID: process.env.AIRBRAKE_PROJECT_ID,
13
20
  PROJECT_KEY: process.env.AIRBRAKE_PROJECT_KEY
14
21
  },
15
22
  };
23
+ const setEnvs = (payload) => {
24
+ NODE_ENV = payload.NODE_ENV;
25
+ env.AIRBRAKE.PROJECT_ID = payload.AIRBRAKE_PROJECT_ID;
26
+ env.AIRBRAKE.PROJECT_KEY = payload.AIRBRAKE_PROJECT_KEY;
27
+ env.VASREFIL.API_KEY = payload.VASREFIL_API_KEY;
28
+ if (payload.VASREFIL_BASEURL) {
29
+ env.VASREFIL.BASEURL = payload.VASREFIL_BASEURL;
30
+ }
31
+ };
32
+ exports.setEnvs = setEnvs;
16
33
  exports.default = env;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './public-api';
1
+ export {};
package/dist/index.js CHANGED
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
17
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
4
  };
@@ -25,8 +11,6 @@ const errorHandler = require("errorhandler");
25
11
  const _config_1 = require("./models/_config");
26
12
  const index_route_1 = require("./routes/index.route");
27
13
  const logger_util_1 = require("./utilities/logger.util");
28
- // Exports
29
- __exportStar(require("./public-api"), exports);
30
14
  // import { airbrake, airbrakeExpress } from './app-middlewares/airbrake';
31
15
  const port = process.env.PORT || 8082;
32
16
  const app = (0, express_1.default)();
@@ -0,0 +1,7 @@
1
+ export interface EnvsI {
2
+ NODE_ENV: string;
3
+ AIRBRAKE_PROJECT_ID: string;
4
+ AIRBRAKE_PROJECT_KEY: string;
5
+ VASREFIL_API_KEY: string;
6
+ VASREFIL_BASEURL?: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,64 @@
1
+ export interface UserI {
2
+ _id: string;
3
+ first_name: string;
4
+ last_name: string;
5
+ middle_name: string;
6
+ email: string;
7
+ email_verified: boolean;
8
+ email_verification_code: string;
9
+ user_name: string;
10
+ password: string;
11
+ balance: number;
12
+ level: number;
13
+ phone: string;
14
+ signup_code: string;
15
+ pin?: string;
16
+ password_reset_code?: string;
17
+ pin_reset_code?: string;
18
+ profile_image_url?: string;
19
+ referrer_commission?: string;
20
+ device_unique_id?: string;
21
+ is_active?: boolean;
22
+ is_deleted?: boolean;
23
+ delete_account_code?: string;
24
+ pin_is_set?: boolean;
25
+ date_of_birth?: Date;
26
+ gender: 'Male' | 'Female';
27
+ bvn?: string;
28
+ bvn_hash?: string;
29
+ nin?: string;
30
+ nin_hash?: string;
31
+ bvn_phone?: string;
32
+ marketing_channel?: string;
33
+ onesignal_player_id_is_set?: boolean;
34
+ vas_service_fee?: number;
35
+ api_key: string;
36
+ bvn_verification_code?: string;
37
+ whatsapp_number?: string;
38
+ address_info: {
39
+ address: string;
40
+ city: string;
41
+ state: string;
42
+ };
43
+ can_use_voucher?: boolean;
44
+ createdAt?: Date;
45
+ }
46
+ export interface UserWalletOperationI {
47
+ find_user_condition: object;
48
+ amount: number;
49
+ action_type: string;
50
+ meta?: Object;
51
+ }
52
+ export interface UserWalletOperationRespI {
53
+ data: {
54
+ user: UserI;
55
+ user_balance: {
56
+ initial_balance: number;
57
+ final_balance: number;
58
+ };
59
+ };
60
+ }
61
+ export interface CheckUserWalletBalanceRespI {
62
+ amount: number;
63
+ user: UserI;
64
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +1,4 @@
1
1
  export * from './controllers';
2
2
  export * from './helpers';
3
+ export * from './utilities';
4
+ export { setEnvs } from './env';
@@ -14,5 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.setEnvs = void 0;
17
18
  __exportStar(require("./controllers"), exports);
18
19
  __exportStar(require("./helpers"), exports);
20
+ __exportStar(require("./utilities"), exports);
21
+ var env_1 = require("./env");
22
+ Object.defineProperty(exports, "setEnvs", { enumerable: true, get: function () { return env_1.setEnvs; } });
@@ -0,0 +1,6 @@
1
+ export declare const VasrefilApiRequest: (request: {
2
+ method: string;
3
+ endpoint: string;
4
+ body?: any;
5
+ params?: any;
6
+ }) => Promise<any>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VasrefilApiRequest = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const env_1 = __importDefault(require("../env"));
9
+ const helpers_1 = require("../helpers");
10
+ const API_KEY = env_1.default.VASREFIL.API_KEY;
11
+ const BASEURL = env_1.default.VASREFIL.BASEURL;
12
+ const VasrefilApiRequest = async (request) => {
13
+ try {
14
+ const headers = { 'api-key': API_KEY };
15
+ const { data } = await axios_1.default.request({
16
+ method: request.method,
17
+ url: `${BASEURL}/${request.endpoint}`,
18
+ data: request.body,
19
+ headers,
20
+ params: request.params,
21
+ });
22
+ return data;
23
+ }
24
+ catch (error) {
25
+ throw {
26
+ error: helpers_1.RequestHelper.get_error(error),
27
+ admin_message: 'Vasrefil-API: send api request failed'
28
+ };
29
+ }
30
+ };
31
+ exports.VasrefilApiRequest = VasrefilApiRequest;
@@ -0,0 +1,3 @@
1
+ export * from './api-request.util';
2
+ export * from './date.util';
3
+ export * from './logger.util';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./api-request.util"), exports);
18
+ __exportStar(require("./date.util"), exports);
19
+ __exportStar(require("./logger.util"), exports);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.0.10",
4
+ "version": "1.0.12",
5
5
  "author": "Sodiq Alabi",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
6
+ "main": "dist/public-api.js",
7
+ "types": "dist/public-api.d.ts",
8
8
  "scripts": {
9
9
  "start": "ts-node-dev src/index.ts",
10
10
  "build": "tsc",
@@ -20,6 +20,7 @@
20
20
  "dependencies": {
21
21
  "@airbrake/node": "^2.1.8",
22
22
  "@types/jsonwebtoken": "^8.5.0",
23
+ "axios": "^1.7.8",
23
24
  "bcrypt": "^5.0.1",
24
25
  "bcrypt-nodejs": "0.0.3",
25
26
  "chalk": "^4.1.0",