@vasrefil/api-toolkit 1.14.6 → 1.14.8

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.
@@ -0,0 +1,68 @@
1
+ import { Status } from '../interfaces/status.interface';
2
+ export declare const ApiResp: {
3
+ NO_AUTHORIZATION_HEADER: {
4
+ code: string;
5
+ status: Status;
6
+ message: string;
7
+ };
8
+ NO_AUTHORIZATION_TOKEN: {
9
+ code: string;
10
+ status: Status;
11
+ message: string;
12
+ };
13
+ NOT_AUTHORIZED: {
14
+ code: string;
15
+ status: Status;
16
+ message: string;
17
+ };
18
+ NO_API_KEY: {
19
+ code: string;
20
+ status: Status;
21
+ message: string;
22
+ };
23
+ USER_NOT_FOUND: {
24
+ code: string;
25
+ status: Status;
26
+ message: string;
27
+ };
28
+ USER_DEACTIVATED: {
29
+ code: string;
30
+ status: Status;
31
+ message: string;
32
+ };
33
+ UNVERIFIED_EMAIL: {
34
+ code: string;
35
+ status: Status;
36
+ message: string;
37
+ };
38
+ UNCOMPELETE_ACCOUNT_SETUP: {
39
+ code: string;
40
+ status: Status;
41
+ message: string;
42
+ };
43
+ UNCOMPELETE_PIN_SETUP: {
44
+ code: string;
45
+ status: Status;
46
+ message: string;
47
+ };
48
+ NO_PIN_TOKEN_HEADER: {
49
+ code: string;
50
+ status: Status;
51
+ message: string;
52
+ };
53
+ EXPIRED_PIN_TOKEN: {
54
+ code: string;
55
+ status: Status;
56
+ message: string;
57
+ };
58
+ CRONJOB_NOT_AUTHORIZED: {
59
+ code: string;
60
+ status: Status;
61
+ message: string;
62
+ };
63
+ NO_CRONJOB_TOKEN: {
64
+ code: string;
65
+ status: Status;
66
+ message: string;
67
+ };
68
+ };
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiResp = void 0;
4
+ const status_interface_1 = require("../interfaces/status.interface");
5
+ exports.ApiResp = {
6
+ NO_AUTHORIZATION_HEADER: {
7
+ code: 'NAH0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify authorization header'
8
+ },
9
+ NO_AUTHORIZATION_TOKEN: {
10
+ code: 'NAT0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify authorization token'
11
+ },
12
+ NOT_AUTHORIZED: {
13
+ code: 'NA00401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'You are not authorized'
14
+ },
15
+ NO_API_KEY: {
16
+ code: 'NAPK0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify api key'
17
+ },
18
+ USER_NOT_FOUND: {
19
+ code: 'UNF0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'User not found'
20
+ },
21
+ USER_DEACTIVATED: {
22
+ code: 'UD00401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Your account has been deactivated'
23
+ },
24
+ UNVERIFIED_EMAIL: {
25
+ code: 'UE00403', status: status_interface_1.Status.FORBIDDEN, message: 'Your email address is not verified'
26
+ },
27
+ UNCOMPELETE_ACCOUNT_SETUP: {
28
+ code: 'UAS0403', status: status_interface_1.Status.FORBIDDEN, message: 'Account setup is not completed'
29
+ },
30
+ UNCOMPELETE_PIN_SETUP: {
31
+ code: 'UPS0403', status: status_interface_1.Status.FORBIDDEN, message: 'Pin setup is not completed'
32
+ },
33
+ NO_PIN_TOKEN_HEADER: {
34
+ code: 'NPTH401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Please specify pin_token header'
35
+ },
36
+ EXPIRED_PIN_TOKEN: {
37
+ code: 'EPT0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Your session has expired, Please login with your pin'
38
+ },
39
+ CRONJOB_NOT_AUTHORIZED: {
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'
44
+ }
45
+ };
@@ -0,0 +1 @@
1
+ export * from './api.response';
@@ -0,0 +1,17 @@
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.response"), exports);
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AdminAuthMidWare = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
- const user_response_1 = require("../api-response/user.response");
8
+ const api_response_1 = require("../api-response/api.response");
9
9
  const _root_service_1 = require("../services/_root.service");
10
10
  const env_1 = __importDefault(require("../env"));
11
11
  const request_helper_1 = require("../helpers/request.helper");
@@ -16,10 +16,10 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
16
16
  try {
17
17
  const authHeader = req.headers.authorization;
18
18
  if (!authHeader)
19
- throw user_response_1.UserApiResp.NO_AUTHORIZATION_HEADER;
19
+ throw api_response_1.ApiResp.NO_AUTHORIZATION_HEADER;
20
20
  const token = authHeader.split(' ')[1];
21
21
  if (!token)
22
- throw user_response_1.UserApiResp.NO_AUTHORIZATION_TOKEN;
22
+ throw api_response_1.ApiResp.NO_AUTHORIZATION_TOKEN;
23
23
  const baseurl = env_1.default.VASREFIL.BASEURL;
24
24
  delete req.headers['host'];
25
25
  delete req.headers['content-length'];
@@ -42,7 +42,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
42
42
  const apiKey = req.headers['api-key'];
43
43
  if (apiKey) {
44
44
  if (apiKey !== valid_api_key)
45
- throw user_response_1.UserApiResp.NO_API_KEY;
45
+ throw api_response_1.ApiResp.NO_API_KEY;
46
46
  }
47
47
  else {
48
48
  const { admin_user } = await this.get_admin(req);
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CronjobMidware = void 0;
7
- const user_response_1 = require("../api-response/user.response");
7
+ const api_response_1 = require("../api-response/api.response");
8
8
  const _root_service_1 = require("../services/_root.service");
9
9
  const env_1 = __importDefault(require("../env"));
10
10
  class CronjobMidware_ extends _root_service_1.RootService {
@@ -15,9 +15,9 @@ class CronjobMidware_ extends _root_service_1.RootService {
15
15
  try {
16
16
  const cronjob_token = req.headers['x-cronjob-token'];
17
17
  if (!cronjob_token)
18
- throw user_response_1.UserApiResp.NO_AUTHORIZATION_TOKEN;
18
+ throw api_response_1.ApiResp.NO_CRONJOB_TOKEN;
19
19
  if (cronjob_token !== valid_cronjob_token)
20
- throw user_response_1.UserApiResp.CRONJOB_NOT_AUTHORIZED;
20
+ throw api_response_1.ApiResp.CRONJOB_NOT_AUTHORIZED;
21
21
  next();
22
22
  }
23
23
  catch (error) {
@@ -7,3 +7,4 @@ export * from './middlewares';
7
7
  export * from './services';
8
8
  export * from './redis';
9
9
  export * from './apis';
10
+ export * from './api-response';
@@ -23,3 +23,4 @@ __exportStar(require("./middlewares"), exports);
23
23
  __exportStar(require("./services"), exports);
24
24
  __exportStar(require("./redis"), exports);
25
25
  __exportStar(require("./apis"), exports);
26
+ __exportStar(require("./api-response"), exports);
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.6",
4
+ "version": "1.14.8",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",