@vasrefil/api-toolkit 1.12.5 → 1.12.6
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 +4 -0
- package/dist/env.js +5 -1
- package/dist/interfaces/notification.interface.d.ts +4 -0
- package/dist/middlewares/admin-auth.midware.d.ts +1 -0
- package/dist/middlewares/admin-auth.midware.js +1 -0
- package/dist/public-api.d.ts +0 -1
- package/dist/public-api.js +0 -1
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +1 -1
- package/dist/utilities/notification.util.d.ts +8 -0
- package/dist/utilities/notification.util.js +56 -0
- package/package.json +1 -1
package/dist/env.d.ts
CHANGED
package/dist/env.js
CHANGED
|
@@ -34,13 +34,17 @@ const env = {
|
|
|
34
34
|
API_KEY: process.env.VASREFIL_EDUCATION_API_KEY
|
|
35
35
|
},
|
|
36
36
|
LOG: {
|
|
37
|
-
BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://log-api.vasrefil.com' : 'https://log-api
|
|
37
|
+
BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://log-api.vasrefil.com' : 'https://log-api.dev.vasrefil.com',
|
|
38
38
|
API_KEY: process.env.VASREFIL_LOG_API_KEY
|
|
39
39
|
},
|
|
40
40
|
LOYALTY: {
|
|
41
41
|
BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://loyalty-api.vasrefil.com' : 'https://loyalty-api-dev.vasrefil.com',
|
|
42
42
|
API_KEY: process.env.VASREFIL_LOYALTY_API_KEY
|
|
43
43
|
},
|
|
44
|
+
NOTIFICATION: {
|
|
45
|
+
BASEURL: process.env.NODE_ENV === NODE_ENVS.PROD ? 'https://notification-api.vasrefil.com' : 'https://notification-api-dev.vasrefil.com',
|
|
46
|
+
API_KEY: process.env.VASREFIL_NOTIFICATION_API_KEY
|
|
47
|
+
},
|
|
44
48
|
AIRBRAKE: {
|
|
45
49
|
PROJECT_ID: process.env.AIRBRAKE_PROJECT_ID,
|
|
46
50
|
PROJECT_KEY: process.env.AIRBRAKE_PROJECT_KEY
|
|
@@ -9,6 +9,7 @@ declare class AdminAuthMidWare_ extends RootService {
|
|
|
9
9
|
edu_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
|
|
10
10
|
log_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
|
|
11
11
|
loyalty_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
|
|
12
|
+
notification_auth: (req: AdminRequestI, res: Response, next: NextFunction) => Promise<any>;
|
|
12
13
|
}
|
|
13
14
|
declare const AdminAuthMidWare: AdminAuthMidWare_;
|
|
14
15
|
export { AdminAuthMidWare };
|
|
@@ -55,6 +55,7 @@ class AdminAuthMidWare_ extends _root_service_1.RootService {
|
|
|
55
55
|
this.edu_auth = this.validate_auth(env_1.default.EDUCATION.API_KEY, 'EDU_ADMIN_AUTH_MIDWARE');
|
|
56
56
|
this.log_auth = this.validate_auth(env_1.default.LOG.API_KEY, 'LOG_ADMIN_AUTH_MIDWARE');
|
|
57
57
|
this.loyalty_auth = this.validate_auth(env_1.default.LOYALTY.API_KEY, 'LOYALTY_ADMIN_AUTH_MIDWARE');
|
|
58
|
+
this.notification_auth = this.validate_auth(env_1.default.NOTIFICATION.API_KEY, 'NOTIFICATION_ADMIN_AUTH_MIDWARE');
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
const AdminAuthMidWare = new AdminAuthMidWare_;
|
package/dist/public-api.d.ts
CHANGED
package/dist/public-api.js
CHANGED
package/dist/utilities/index.js
CHANGED
|
@@ -20,5 +20,5 @@ __exportStar(require("./logger.util"), exports);
|
|
|
20
20
|
__exportStar(require("./log.util"), exports);
|
|
21
21
|
__exportStar(require("./go-mailer.util"), exports);
|
|
22
22
|
__exportStar(require("./report.util"), exports);
|
|
23
|
-
__exportStar(require("./
|
|
23
|
+
__exportStar(require("./notification.util"), exports);
|
|
24
24
|
__exportStar(require("./ip.util"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ISendEmailPayload, ISendPushPayload } from '../interfaces/notification.interface';
|
|
2
|
+
declare class NotificationUtil_ {
|
|
3
|
+
send_email: (payload: ISendEmailPayload[]) => Promise<any>;
|
|
4
|
+
send_push: (payload: ISendPushPayload[]) => Promise<any>;
|
|
5
|
+
private api_request;
|
|
6
|
+
}
|
|
7
|
+
export declare const NotificationUtil: NotificationUtil_;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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.NotificationUtil = void 0;
|
|
7
|
+
const helpers_1 = require("../helpers");
|
|
8
|
+
const api_request_util_1 = require("./api-request.util");
|
|
9
|
+
const env_1 = __importDefault(require("../env"));
|
|
10
|
+
class NotificationUtil_ {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.send_email = async (payload) => {
|
|
13
|
+
try {
|
|
14
|
+
const resp = await this.api_request({
|
|
15
|
+
method: 'POST',
|
|
16
|
+
endpoint: 'emails/send',
|
|
17
|
+
body: payload
|
|
18
|
+
});
|
|
19
|
+
return resp;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
this.send_push = async (payload) => {
|
|
27
|
+
try {
|
|
28
|
+
const resp = await this.api_request({
|
|
29
|
+
method: 'POST',
|
|
30
|
+
endpoint: 'push/send',
|
|
31
|
+
body: payload
|
|
32
|
+
});
|
|
33
|
+
return resp;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.api_request = async (request) => {
|
|
41
|
+
try {
|
|
42
|
+
const resp = await (0, api_request_util_1.ApiRequest)({
|
|
43
|
+
baseurl: env_1.default.NOTIFICATION.BASEURL,
|
|
44
|
+
apiKey: env_1.default.NOTIFICATION.API_KEY,
|
|
45
|
+
...request,
|
|
46
|
+
});
|
|
47
|
+
return resp;
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const err = helpers_1.RequestHelper.get_error(error);
|
|
51
|
+
console.log(`Send Email error: ${err?.message}`);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.NotificationUtil = new NotificationUtil_();
|