@vasrefil/api-toolkit 1.13.8 → 1.14.5

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.
@@ -55,4 +55,9 @@ export declare const UserApiResp: {
55
55
  status: Status;
56
56
  message: string;
57
57
  };
58
+ CRONJOB_NOT_AUTHORIZED: {
59
+ code: string;
60
+ status: Status;
61
+ message: string;
62
+ };
58
63
  };
@@ -36,4 +36,7 @@ exports.UserApiResp = {
36
36
  EXPIRED_PIN_TOKEN: {
37
37
  code: 'EPT0401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Your session has expired, Please login with your pin'
38
38
  },
39
+ CRONJOB_NOT_AUTHORIZED: {
40
+ code: 'CRJNA401', status: status_interface_1.Status.UN_AUTHORIZED, message: 'Access failed. try again later'
41
+ }
39
42
  };
package/dist/env.d.ts CHANGED
@@ -43,5 +43,6 @@ declare const env: {
43
43
  GO_MAILER: {
44
44
  API_KEY: string;
45
45
  };
46
+ CRONJOB_TOKEN: string;
46
47
  };
47
48
  export default env;
package/dist/env.js CHANGED
@@ -51,6 +51,7 @@ const env = {
51
51
  },
52
52
  GO_MAILER: {
53
53
  API_KEY: process.env.GO_MAILER_API_KEY
54
- }
54
+ },
55
+ CRONJOB_TOKEN: process.env.CRONJOB_TOKEN
55
56
  };
56
57
  exports.default = env;
@@ -10,6 +10,7 @@ export interface ISendEmailPayload {
10
10
  job_options?: BulkJobOptions;
11
11
  }
12
12
  export interface ISendPushPayload {
13
+ distinct_id: string;
13
14
  name: string;
14
15
  content: string;
15
16
  heading: string;
@@ -0,0 +1,8 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ import { RootService } from '../services/_root.service';
3
+ declare class CronjobMidware_ extends RootService {
4
+ private validate_auth;
5
+ auth: (req: Request, res: Response, next: NextFunction) => Promise<any>;
6
+ }
7
+ export declare const CronjobMidware: CronjobMidware_;
8
+ export {};
@@ -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.CronjobMidware = void 0;
7
+ const user_response_1 = require("../api-response/user.response");
8
+ const _root_service_1 = require("../services/_root.service");
9
+ const env_1 = __importDefault(require("../env"));
10
+ class CronjobMidware_ extends _root_service_1.RootService {
11
+ constructor() {
12
+ super(...arguments);
13
+ this.validate_auth = (valid_cronjob_token, actionType) => {
14
+ return async (req, res, next) => {
15
+ try {
16
+ const cronjob_token = req.headers['x-cronjob-token'];
17
+ if (cronjob_token !== valid_cronjob_token)
18
+ throw user_response_1.UserApiResp.CRONJOB_NOT_AUTHORIZED;
19
+ next();
20
+ }
21
+ catch (error) {
22
+ console.log('cronjob_auth_error', error);
23
+ const { status, message, data } = this.get_error(error);
24
+ return this.sendResponse({ req, res, status, actionType, message, data, error });
25
+ }
26
+ };
27
+ };
28
+ this.auth = this.validate_auth(env_1.default.CRONJOB_TOKEN, 'CRONJOB_AUTH_MIDWARE');
29
+ }
30
+ }
31
+ exports.CronjobMidware = new CronjobMidware_;
@@ -1,3 +1,4 @@
1
1
  export * from './admin-auth.midware';
2
2
  export * from './user-auth.midware';
3
3
  export * from './validator.midware';
4
+ export * from './cronjob.midware';
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./admin-auth.midware"), exports);
18
18
  __exportStar(require("./user-auth.midware"), exports);
19
19
  __exportStar(require("./validator.midware"), exports);
20
+ __exportStar(require("./cronjob.midware"), 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.13.8",
4
+ "version": "1.14.5",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",