@vasrefil/api-toolkit 1.0.42 → 1.0.45

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.
@@ -5,6 +5,7 @@ declare class AdminAuthMidWare_ extends RootService {
5
5
  auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
6
6
  voucher_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
7
7
  edu_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
8
+ log_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
8
9
  private get_admin;
9
10
  }
10
11
  declare const AdminAuthMidWare: AdminAuthMidWare_;
@@ -69,6 +69,25 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
69
69
  return this.sendResponse({ req, res, status, actionType, message, data, error });
70
70
  }
71
71
  };
72
+ this.log_auth = async (req, res, next) => {
73
+ const actionType = 'LOG_ADMIN_AUTH_MIDWARE';
74
+ try {
75
+ const apiKey = req.headers['api-key'];
76
+ if (apiKey) {
77
+ if (apiKey !== env_1.default.LOG.API_KEY)
78
+ throw user_response_1.UserApiResp.NO_API_KEY;
79
+ }
80
+ else {
81
+ const { admin_user } = await this.get_admin(req);
82
+ req.admin = admin_user;
83
+ }
84
+ next();
85
+ }
86
+ catch (error) {
87
+ const { status, message, data } = this.get_error(error);
88
+ return this.sendResponse({ req, res, status, actionType, message, data, error });
89
+ }
90
+ };
72
91
  this.get_admin = async (req) => {
73
92
  try {
74
93
  const baseurl = env_1.default.VASREFIL.BASEURL;
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@vasrefil/api-toolkit",
3
+ "description": "This is Vasrefil API toolkit",
4
+ "version": "1.0.43",
5
+ "author": "Sodiq Alabi",
6
+ "main": "dist/public-api.js",
7
+ "types": "dist/public-api.d.ts",
8
+ "scripts": {
9
+ "start": "ts-node-dev src/index.ts",
10
+ "build": "tsc",
11
+ "prepublishOnly": "npm run build",
12
+ "serve": "node dist/index.js",
13
+ "dev": "nodemon --exec ts-node src/index.ts",
14
+ "run-ts-node": "ts-node-dev"
15
+ },
16
+ "engines": {
17
+ "node": "20.11.0",
18
+ "npm": "10.2.4"
19
+ },
20
+ "dependencies": {
21
+ "@airbrake/node": "^2.1.8",
22
+ "@types/jsonwebtoken": "^8.5.0",
23
+ "axios": "^1.7.8",
24
+ "chalk": "^4.1.0",
25
+ "cors": "^2.8.5",
26
+ "date-fns": "^2.29.3",
27
+ "dotenv": "^8.2.0",
28
+ "errorhandler": "^1.5.1",
29
+ "express": "^4.18.3",
30
+ "helmet": "^4.2.0",
31
+ "ioredis": "^5.4.1",
32
+ "joi": "^17.3.0",
33
+ "json-stringify-safe": "^5.0.1",
34
+ "mongoose": "^6.0.14",
35
+ "morgan": "^1.10.0",
36
+ "winston": "^3.3.3"
37
+ },
38
+ "devDependencies": {
39
+ "@types/body-parser": "1.19.0",
40
+ "@types/cors": "^2.8.17",
41
+ "@types/errorhandler": "1.5.0",
42
+ "@types/morgan": "^1.9.3",
43
+ "@types/node": "^14.14.7",
44
+ "cross-env": "^7.0.2",
45
+ "nodemon": "^3.1.0",
46
+ "ts-node": "^10.9.2",
47
+ "ts-node-dev": "^2.0.0",
48
+ "typescript": "^5.3.3"
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "README.md"
53
+ ]
54
+ }
@@ -27,6 +27,7 @@ class LogUtil_ {
27
27
  type: 'USER_EVENT',
28
28
  response_status: status,
29
29
  };
30
+ console.log('user_event-request', payload.request);
30
31
  await this.create_activity_log(payload);
31
32
  }
32
33
  }
@@ -39,6 +40,7 @@ class LogUtil_ {
39
40
  }
40
41
  };
41
42
  this.get_request = (req) => {
43
+ console.log('req.headers', req.headers);
42
44
  const { authorization, pin_token, ...headers_ } = req.headers;
43
45
  const { password, pin, old_pin, new_pin, bvn, nin, file, ...body_ } = req.body;
44
46
  const { params, query, method, url, statusCode } = req;
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.42",
4
+ "version": "1.0.45",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",