@triproject/nestjs-core 1.0.5 → 1.0.13

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.
Files changed (55) hide show
  1. package/.swcrc +24 -0
  2. package/README.md +297 -38
  3. package/dist/bootstrap.js +1 -43
  4. package/dist/config.js +1 -50
  5. package/dist/controllers/controller.js +1 -56
  6. package/dist/drivers/cache/cache.d.ts +1 -1
  7. package/dist/drivers/cache/cache.driver.js +1 -22
  8. package/dist/drivers/cache/cache.js +1 -92
  9. package/dist/drivers/cache/index.js +1 -19
  10. package/dist/drivers/cache/redis.js +1 -52
  11. package/dist/drivers/db/db.helper.js +1 -217
  12. package/dist/drivers/db/db.module.js +1 -44
  13. package/dist/drivers/db/db.service.js +1 -49
  14. package/dist/drivers/db/index.js +1 -21
  15. package/dist/drivers/db/migration.d.ts +133 -5
  16. package/dist/drivers/db/migration.js +1 -81
  17. package/dist/drivers/db/repository.js +1 -255
  18. package/dist/drivers/encryptions/encryption.js +1 -50
  19. package/dist/drivers/encryptions/encryption.module.js +1 -24
  20. package/dist/drivers/encryptions/index.js +1 -19
  21. package/dist/drivers/encryptions/jwt.js +1 -46
  22. package/dist/drivers/encryptions/password-hash.js +1 -38
  23. package/dist/drivers/encryptions/snap.signature.js +1 -110
  24. package/dist/drivers/logger/app.logger.js +2 -183
  25. package/dist/drivers/logger/cloudwatch.d.ts +18 -0
  26. package/dist/drivers/logger/cloudwatch.js +1 -0
  27. package/dist/drivers/logger/cloudwatch.logger.d.ts +1 -0
  28. package/dist/drivers/logger/cloudwatch.logger.js +1 -0
  29. package/dist/drivers/logger/index.js +1 -18
  30. package/dist/drivers/logger/slack.logger.js +1 -24
  31. package/dist/drivers/mail/index.js +1 -22
  32. package/dist/drivers/mail/mail-template.js +8 -41
  33. package/dist/drivers/mail/mail.config.js +1 -4
  34. package/dist/drivers/mail/mail.js +13 -73
  35. package/dist/drivers/mail/mail.module.js +1 -26
  36. package/dist/drivers/mail/mail.queue.js +1 -37
  37. package/dist/drivers/mail/mailer.js +1 -62
  38. package/dist/drivers/notifications/index.js +1 -21
  39. package/dist/drivers/notifications/notification.config.js +1 -4
  40. package/dist/drivers/notifications/notification.module.js +1 -25
  41. package/dist/drivers/notifications/notification.queue.js +1 -37
  42. package/dist/drivers/notifications/push-notification.js +1 -75
  43. package/dist/drivers/notifications/slack.js +1 -95
  44. package/dist/drivers/queues/app.queue.js +1 -66
  45. package/dist/drivers/queues/index.js +1 -18
  46. package/dist/drivers/queues/queue.module.js +1 -41
  47. package/dist/helpers/exception.helper.js +1 -71
  48. package/dist/helpers/http.helper.js +1 -134
  49. package/dist/helpers/swagger.helper.js +1 -287
  50. package/dist/helpers/totp.helper.js +1 -30
  51. package/dist/index.d.ts +1 -0
  52. package/dist/index.js +1 -24
  53. package/dist/middlewares/log.middleware.js +1 -59
  54. package/dist/types.d.js +1 -0
  55. package/package.json +27 -14
@@ -1,26 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MailModule = void 0;
10
- const bull_1 = require("@nestjs/bull");
11
- const common_1 = require("@nestjs/common");
12
- const mail_template_1 = require("./mail-template");
13
- const mail_config_1 = require("./mail.config");
14
- const mail_queue_1 = require("./mail.queue");
15
- const mailer_1 = require("./mailer");
16
- let MailModule = class MailModule {
17
- };
18
- exports.MailModule = MailModule;
19
- exports.MailModule = MailModule = __decorate([
20
- (0, common_1.Global)(),
21
- (0, common_1.Module)({
22
- providers: [mailer_1.Mailer, mail_template_1.MailTemplate, mail_queue_1.MailQueue],
23
- exports: [mailer_1.Mailer, mail_template_1.MailTemplate],
24
- imports: [bull_1.BullModule.registerQueue({ name: mail_config_1.mailerQueue })],
25
- })
26
- ], MailModule);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"MailModule",{enumerable:!0,get:function(){return MailModule}});let _bull=require("@nestjs/bull"),_common=require("@nestjs/common"),_mailtemplate=require("./mail-template"),_mailconfig=require("./mail.config"),_mailqueue=require("./mail.queue"),_mailer=require("./mailer");let MailModule=class MailModule{};MailModule=function(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}([(0,_common.Global)(),(0,_common.Module)({providers:[_mailer.Mailer,_mailtemplate.MailTemplate,_mailqueue.MailQueue],exports:[_mailer.Mailer,_mailtemplate.MailTemplate],imports:[_bull.BullModule.registerQueue({name:_mailconfig.mailerQueue})]})],MailModule);
@@ -1,37 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.MailQueue = void 0;
13
- const bull_1 = require("@nestjs/bull");
14
- const app_queue_1 = require("../queues/app.queue");
15
- const mail_config_1 = require("./mail.config");
16
- const mailer_1 = require("./mailer");
17
- let MailQueue = class MailQueue extends app_queue_1.AppQueue {
18
- mailer;
19
- constructor(mailer) {
20
- super();
21
- this.mailer = mailer;
22
- }
23
- async addLog({ data }) {
24
- await this.mailer.send(data, false);
25
- }
26
- };
27
- exports.MailQueue = MailQueue;
28
- __decorate([
29
- (0, bull_1.Process)({ name: mail_config_1.mailerQueue, concurrency: 4 }),
30
- __metadata("design:type", Function),
31
- __metadata("design:paramtypes", [Object]),
32
- __metadata("design:returntype", Promise)
33
- ], MailQueue.prototype, "addLog", null);
34
- exports.MailQueue = MailQueue = __decorate([
35
- (0, bull_1.Processor)(mail_config_1.mailerQueue),
36
- __metadata("design:paramtypes", [mailer_1.Mailer])
37
- ], MailQueue);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"MailQueue",{enumerable:!0,get:function(){return MailQueue}});let _bull=require("@nestjs/bull"),_bull1=require("bull"),_appqueue=require("../queues/app.queue"),_mailconfig=require("./mail.config"),_mailer=require("./mailer");function _ts_decorate(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}function _ts_metadata(k,v){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(k,v)}let MailQueue=class MailQueue extends _appqueue.AppQueue{mailer;constructor(mailer){super(),this.mailer=mailer}async addLog({data}){await this.mailer.send(data,!1)}};_ts_decorate([(0,_bull.Process)({name:_mailconfig.mailerQueue,concurrency:4}),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",Promise)],MailQueue.prototype,"addLog",null),MailQueue=_ts_decorate([(0,_bull.Processor)(_mailconfig.mailerQueue),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_mailer.Mailer?Object:_mailer.Mailer])],MailQueue);
@@ -1,62 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.Mailer = void 0;
16
- const bull_1 = require("@nestjs/bull");
17
- const common_1 = require("@nestjs/common");
18
- const helpers_1 = require("@triproject/helpers");
19
- const nodemailer_1 = require("nodemailer");
20
- const config_1 = require("../../config");
21
- const mail_template_1 = require("./mail-template");
22
- const mail_config_1 = require("./mail.config");
23
- let Mailer = class Mailer {
24
- mailTemplate;
25
- mailerQueue;
26
- EMAIL_FROM;
27
- mailer;
28
- constructor(mailTemplate, mailerQueue) {
29
- this.mailTemplate = mailTemplate;
30
- this.mailerQueue = mailerQueue;
31
- this.EMAIL_FROM = config_1.MAIL_FROM_EMAIL;
32
- this.mailer = (0, nodemailer_1.createTransport)({
33
- host: config_1.MAIL_HOST,
34
- port: config_1.MAIL_PORT,
35
- auth: { user: config_1.MAIL_USERNAME, pass: config_1.MAIL_PASSWORD },
36
- });
37
- }
38
- async _queue(params) {
39
- const data = {
40
- from: this.EMAIL_FROM,
41
- to: `${params.name} <${params.email}>`,
42
- cc: params.cc,
43
- bcc: params.bcc,
44
- subject: params.subject,
45
- html: this.mailTemplate.html(params.mail.toString()),
46
- };
47
- await this.mailerQueue.add(mail_config_1.mailerQueue, data, {
48
- jobId: (0, helpers_1.generateId)(),
49
- });
50
- }
51
- async send(params, shouldQueue = true) {
52
- if (shouldQueue)
53
- return await this._queue(params);
54
- return await this.mailer.sendMail(params);
55
- }
56
- };
57
- exports.Mailer = Mailer;
58
- exports.Mailer = Mailer = __decorate([
59
- (0, common_1.Injectable)(),
60
- __param(1, (0, bull_1.InjectQueue)(mail_config_1.mailerQueue)),
61
- __metadata("design:paramtypes", [mail_template_1.MailTemplate, Object])
62
- ], Mailer);
1
+ "use strict";var decorator;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Mailer",{enumerable:!0,get:function(){return Mailer}});let _bull=require("@nestjs/bull"),_common=require("@nestjs/common"),_helpers=require("@triproject/helpers"),_bull1=require("bull"),_nodemailer=require("nodemailer"),_config=require("../../config"),_mailtemplate=require("./mail-template"),_mailconfig=require("./mail.config");function _ts_metadata(k,v){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(k,v)}let Mailer=class Mailer{mailTemplate;mailerQueue;EMAIL_FROM;mailer;constructor(mailTemplate,mailerQueue){this.mailTemplate=mailTemplate,this.mailerQueue=mailerQueue,this.EMAIL_FROM=_config.MAIL_FROM_EMAIL,this.mailer=(0,_nodemailer.createTransport)({host:_config.MAIL_HOST,port:_config.MAIL_PORT,auth:{user:_config.MAIL_USERNAME,pass:_config.MAIL_PASSWORD}})}async _queue(params){let data={from:this.EMAIL_FROM,to:`${params.name} <${params.email}>`,cc:params.cc,bcc:params.bcc,subject:params.subject,html:this.mailTemplate.html(params.mail.toString())};await this.mailerQueue.add(_mailconfig.mailerQueue,data,{jobId:(0,_helpers.generateId)()})}async send(params,shouldQueue=!0){return shouldQueue?await this._queue(params):await this.mailer.sendMail(params)}};Mailer=function(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}([(0,_common.Injectable)(),(decorator=(0,_bull.InjectQueue)(_mailconfig.mailerQueue),function(target,key){decorator(target,key,1)}),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_mailtemplate.MailTemplate?Object:_mailtemplate.MailTemplate,void 0===_bull1.Queue?Object:_bull1.Queue])],Mailer);
@@ -1,21 +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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./notification.config"), exports);
18
- __exportStar(require("./notification.module"), exports);
19
- __exportStar(require("./notification.queue"), exports);
20
- __exportStar(require("./push-notification"), exports);
21
- __exportStar(require("./slack"), exports);
1
+ "use strict";function _export_star(from,to){return Object.keys(from).forEach(function(k){"default"===k||Object.prototype.hasOwnProperty.call(to,k)||Object.defineProperty(to,k,{enumerable:!0,get:function(){return from[k]}})}),from}Object.defineProperty(exports,"__esModule",{value:!0}),_export_star(require("./notification.config"),exports),_export_star(require("./notification.module"),exports),_export_star(require("./notification.queue"),exports),_export_star(require("./push-notification"),exports),_export_star(require("./slack"),exports);
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.notificationQueue = void 0;
4
- exports.notificationQueue = 'NOTIFICATION:QUEUE';
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"notificationQueue",{enumerable:!0,get:function(){return notificationQueue}});let notificationQueue="NOTIFICATION:QUEUE";
@@ -1,25 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.NotificationDriverModule = void 0;
10
- const bull_1 = require("@nestjs/bull");
11
- const common_1 = require("@nestjs/common");
12
- const notification_config_1 = require("./notification.config");
13
- const notification_queue_1 = require("./notification.queue");
14
- const push_notification_1 = require("./push-notification");
15
- let NotificationDriverModule = class NotificationDriverModule {
16
- };
17
- exports.NotificationDriverModule = NotificationDriverModule;
18
- exports.NotificationDriverModule = NotificationDriverModule = __decorate([
19
- (0, common_1.Global)(),
20
- (0, common_1.Module)({
21
- providers: [push_notification_1.PushNotification, notification_queue_1.NotificationQueue],
22
- imports: [bull_1.BullModule.registerQueue({ name: notification_config_1.notificationQueue })],
23
- exports: [push_notification_1.PushNotification],
24
- })
25
- ], NotificationDriverModule);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"NotificationDriverModule",{enumerable:!0,get:function(){return NotificationDriverModule}});let _bull=require("@nestjs/bull"),_common=require("@nestjs/common"),_notificationconfig=require("./notification.config"),_notificationqueue=require("./notification.queue"),_pushnotification=require("./push-notification");let NotificationDriverModule=class NotificationDriverModule{};NotificationDriverModule=function(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}([(0,_common.Global)(),(0,_common.Module)({providers:[_pushnotification.PushNotification,_notificationqueue.NotificationQueue],imports:[_bull.BullModule.registerQueue({name:_notificationconfig.notificationQueue})],exports:[_pushnotification.PushNotification]})],NotificationDriverModule);
@@ -1,37 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.NotificationQueue = void 0;
13
- const bull_1 = require("@nestjs/bull");
14
- const app_queue_1 = require("../queues/app.queue");
15
- const notification_config_1 = require("./notification.config");
16
- const push_notification_1 = require("./push-notification");
17
- let NotificationQueue = class NotificationQueue extends app_queue_1.AppQueue {
18
- pushNotification;
19
- constructor(pushNotification) {
20
- super();
21
- this.pushNotification = pushNotification;
22
- }
23
- async sendNotification({ data }) {
24
- await this.pushNotification.send(data, false);
25
- }
26
- };
27
- exports.NotificationQueue = NotificationQueue;
28
- __decorate([
29
- (0, bull_1.Process)({ name: notification_config_1.notificationQueue, concurrency: 4 }),
30
- __metadata("design:type", Function),
31
- __metadata("design:paramtypes", [Object]),
32
- __metadata("design:returntype", Promise)
33
- ], NotificationQueue.prototype, "sendNotification", null);
34
- exports.NotificationQueue = NotificationQueue = __decorate([
35
- (0, bull_1.Processor)(notification_config_1.notificationQueue),
36
- __metadata("design:paramtypes", [push_notification_1.PushNotification])
37
- ], NotificationQueue);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"NotificationQueue",{enumerable:!0,get:function(){return NotificationQueue}});let _bull=require("@nestjs/bull"),_bull1=require("bull"),_appqueue=require("../queues/app.queue"),_notificationconfig=require("./notification.config"),_pushnotification=require("./push-notification");function _ts_decorate(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}function _ts_metadata(k,v){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(k,v)}let NotificationQueue=class NotificationQueue extends _appqueue.AppQueue{pushNotification;constructor(pushNotification){super(),this.pushNotification=pushNotification}async sendNotification({data}){await this.pushNotification.send(data,!1)}};_ts_decorate([(0,_bull.Process)({name:_notificationconfig.notificationQueue,concurrency:4}),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",Promise)],NotificationQueue.prototype,"sendNotification",null),NotificationQueue=_ts_decorate([(0,_bull.Processor)(_notificationconfig.notificationQueue),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_pushnotification.PushNotification?Object:_pushnotification.PushNotification])],NotificationQueue);
@@ -1,75 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.PushNotification = void 0;
19
- const bull_1 = require("@nestjs/bull");
20
- const common_1 = require("@nestjs/common");
21
- const helpers_1 = require("@triproject/helpers");
22
- const axios_1 = __importDefault(require("axios"));
23
- const bullmq_1 = require("bullmq");
24
- const config_1 = require("../../config");
25
- const notification_config_1 = require("./notification.config");
26
- let PushNotification = class PushNotification {
27
- notificationQueue;
28
- APP_ID;
29
- client;
30
- constructor(notificationQueue) {
31
- this.notificationQueue = notificationQueue;
32
- this.APP_ID = config_1.ONESIGNAL_APP_ID;
33
- this.client = axios_1.default.create({
34
- baseURL: 'https://api.onesignal.com',
35
- timeout: 100,
36
- headers: {
37
- 'Content-Type': 'application/json; charset=utf-8',
38
- Authorization: `Key ${config_1.ONESIGNAL_REST_API_KEY}`,
39
- },
40
- });
41
- }
42
- async send(params, shouldQueue = true) {
43
- if (shouldQueue) {
44
- return this.notificationQueue.add(notification_config_1.notificationQueue, params, {
45
- jobId: (0, helpers_1.generateId)(),
46
- });
47
- }
48
- const { userId, type, title, message, data } = params;
49
- return await this.client.post('notifications', {
50
- app_id: this.APP_ID,
51
- target_channel: 'push',
52
- name: type,
53
- headings: { en: title },
54
- contents: { en: message },
55
- data,
56
- included_segments: [userId].filter((d) => d),
57
- });
58
- }
59
- broadcast(params, shouldQueue = true) {
60
- const { title, message, data } = params;
61
- return this.send({
62
- userId: 'All',
63
- type: 'broadcast',
64
- title,
65
- message,
66
- data,
67
- }, shouldQueue);
68
- }
69
- };
70
- exports.PushNotification = PushNotification;
71
- exports.PushNotification = PushNotification = __decorate([
72
- (0, common_1.Injectable)(),
73
- __param(0, (0, bull_1.InjectQueue)(notification_config_1.notificationQueue)),
74
- __metadata("design:paramtypes", [bullmq_1.Queue])
75
- ], PushNotification);
1
+ "use strict";var decorator,obj;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"PushNotification",{enumerable:!0,get:function(){return PushNotification}});let _bull=require("@nestjs/bull"),_common=require("@nestjs/common"),_helpers=require("@triproject/helpers"),_axios=(obj=require("axios"))&&obj.__esModule?obj:{default:obj},_bullmq=require("bullmq"),_config=require("../../config"),_notificationconfig=require("./notification.config");function _ts_metadata(k,v){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(k,v)}let PushNotification=class PushNotification{notificationQueue;APP_ID;client;constructor(notificationQueue){this.notificationQueue=notificationQueue,this.APP_ID=_config.ONESIGNAL_APP_ID,this.client=_axios.default.create({baseURL:"https://api.onesignal.com",timeout:100,headers:{"Content-Type":"application/json; charset=utf-8",Authorization:`Key ${_config.ONESIGNAL_REST_API_KEY}`}})}async send(params,shouldQueue=!0){if(shouldQueue)return this.notificationQueue.add(_notificationconfig.notificationQueue,params,{jobId:(0,_helpers.generateId)()});let{userId,type,title,message,data}=params;return await this.client.post("notifications",{app_id:this.APP_ID,target_channel:"push",name:type,headings:{en:title},contents:{en:message},data,included_segments:[userId].filter(d=>d)})}broadcast(params,shouldQueue=!0){let{title,message,data}=params;return this.send({userId:"All",type:"broadcast",title,message,data},shouldQueue)}};PushNotification=function(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}([(0,_common.Injectable)(),(decorator=(0,_bull.InjectQueue)(_notificationconfig.notificationQueue),function(target,key){decorator(target,key,0)}),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bullmq.Queue?Object:_bullmq.Queue])],PushNotification);
@@ -1,95 +1 @@
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.Slack = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
- class Slack {
9
- logger = console;
10
- client;
11
- status = {
12
- blocked: false,
13
- lastUpdateAt: new Date(),
14
- };
15
- constructor(config) {
16
- if (config.logger)
17
- this.logger = config.logger;
18
- if (config.webhookUrl.startsWith('https')) {
19
- this.client = axios_1.default.create({
20
- baseURL: config.webhookUrl,
21
- timeout: 500,
22
- headers: { 'Content-Type': 'application/json' },
23
- });
24
- }
25
- }
26
- _toggleBlocked() {
27
- this.status = {
28
- blocked: !this.status.blocked,
29
- lastUpdateAt: new Date(),
30
- };
31
- }
32
- _format(...messages) {
33
- const blocks = [];
34
- if (messages.length === 0)
35
- return blocks;
36
- if (messages.length > 0 && typeof messages[0] === 'string') {
37
- blocks.push({
38
- type: 'header',
39
- text: { type: 'plain_text', text: messages[0] },
40
- });
41
- return blocks;
42
- }
43
- for (const msg of messages) {
44
- if (!msg)
45
- continue;
46
- if (msg instanceof Error) {
47
- blocks.push({
48
- type: 'section',
49
- text: {
50
- type: 'mrkdwn',
51
- text: '<font color="red">```**' +
52
- msg.name +
53
- '**: ' +
54
- msg.message +
55
- '\n ' +
56
- msg?.stack?.split('\n').join('\n ') +
57
- '</font>```',
58
- },
59
- });
60
- }
61
- else if (typeof msg === 'object') {
62
- blocks.push({
63
- type: 'section',
64
- text: { type: 'mrkdwn', text: '```json' + JSON.stringify(msg, null, 2) + '```' },
65
- });
66
- }
67
- else {
68
- blocks.push({
69
- type: 'section',
70
- text: { type: 'plain_text', text: msg?.toString() },
71
- });
72
- }
73
- }
74
- return blocks;
75
- }
76
- async send(...messages) {
77
- if (!this.client)
78
- return;
79
- if (this.status.blocked && new Date().getTime() - this.status.lastUpdateAt.getTime() < 60_000 * 60 * 3)
80
- return;
81
- return await this.client
82
- .post('', { blocks: this._format(...messages) })
83
- .then((data) => {
84
- if (this.status.blocked)
85
- this._toggleBlocked();
86
- return data;
87
- })
88
- .catch((error) => {
89
- this?.logger.error('Failed to send slack notification', error);
90
- if (!this.status.blocked)
91
- this._toggleBlocked();
92
- });
93
- }
94
- }
95
- exports.Slack = Slack;
1
+ "use strict";var obj;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"Slack",{enumerable:!0,get:function(){return Slack}});let _axios=(obj=require("axios"))&&obj.__esModule?obj:{default:obj};let Slack=class Slack{logger=console;client;status={blocked:!1,lastUpdateAt:new Date};constructor(config){config.logger&&(this.logger=config.logger),config.webhookUrl.startsWith("https")&&(this.client=_axios.default.create({baseURL:config.webhookUrl,timeout:500,headers:{"Content-Type":"application/json"}}))}_toggleBlocked(){this.status={blocked:!this.status.blocked,lastUpdateAt:new Date}}_format(...messages){let blocks=[];if(0===messages.length)return blocks;if(messages.length>0&&"string"==typeof messages[0])return blocks.push({type:"header",text:{type:"plain_text",text:messages[0]}}),blocks;for(let msg of messages)msg&&(msg instanceof Error?blocks.push({type:"section",text:{type:"mrkdwn",text:'<font color="red">```**'+msg.name+"**: "+msg.message+"\n "+msg?.stack?.split("\n").join("\n ")+"</font>```"}}):"object"==typeof msg?blocks.push({type:"section",text:{type:"mrkdwn",text:"```json"+JSON.stringify(msg,null,2)+"```"}}):blocks.push({type:"section",text:{type:"plain_text",text:msg?.toString()}}));return blocks}async send(...messages){if(this.client&&!(this.status.blocked&&new Date().getTime()-this.status.lastUpdateAt.getTime()<108e5))return await this.client.post("",{blocks:this._format(...messages)}).then(data=>(this.status.blocked&&this._toggleBlocked(),data)).catch(error=>{this?.logger.error("Failed to send slack notification",error),this.status.blocked||this._toggleBlocked()})}};
@@ -1,66 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AppQueue = void 0;
13
- const bull_1 = require("@nestjs/bull");
14
- const app_logger_1 = require("../logger/app.logger");
15
- class AppQueue {
16
- logger = new app_logger_1.AppLogger(this.constructor.name);
17
- constructor() {
18
- this.logger.log(this.constructor.name + ' is ready');
19
- }
20
- onProgress(job) {
21
- this.logger.log(`Job ${job.id} in ${job.name} is active`, job.data);
22
- }
23
- onCompleted(job) {
24
- this.logger.log(`Job ${job.id} in ${job.name} is completed`, job.data);
25
- }
26
- onStalled(job) {
27
- this.logger.error(`Job ${job.id} in ${job.name} is stalled`, job.data);
28
- }
29
- onError(job) {
30
- this.logger.error(`Job ${job.id} in ${job.name} is error`, job.data);
31
- }
32
- onFailed(job, error) {
33
- this.logger.error(`Job ${job.id} in ${job.name} is failed`, job.data, error);
34
- }
35
- }
36
- exports.AppQueue = AppQueue;
37
- __decorate([
38
- (0, bull_1.OnQueueProgress)(),
39
- __metadata("design:type", Function),
40
- __metadata("design:paramtypes", [Object]),
41
- __metadata("design:returntype", void 0)
42
- ], AppQueue.prototype, "onProgress", null);
43
- __decorate([
44
- (0, bull_1.OnQueueCompleted)(),
45
- __metadata("design:type", Function),
46
- __metadata("design:paramtypes", [Object]),
47
- __metadata("design:returntype", void 0)
48
- ], AppQueue.prototype, "onCompleted", null);
49
- __decorate([
50
- (0, bull_1.OnQueueStalled)(),
51
- __metadata("design:type", Function),
52
- __metadata("design:paramtypes", [Object]),
53
- __metadata("design:returntype", void 0)
54
- ], AppQueue.prototype, "onStalled", null);
55
- __decorate([
56
- (0, bull_1.OnQueueError)(),
57
- __metadata("design:type", Function),
58
- __metadata("design:paramtypes", [Object]),
59
- __metadata("design:returntype", void 0)
60
- ], AppQueue.prototype, "onError", null);
61
- __decorate([
62
- (0, bull_1.OnQueueFailed)(),
63
- __metadata("design:type", Function),
64
- __metadata("design:paramtypes", [Object, Object]),
65
- __metadata("design:returntype", void 0)
66
- ], AppQueue.prototype, "onFailed", null);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"AppQueue",{enumerable:!0,get:function(){return AppQueue}});let _bull=require("@nestjs/bull"),_bull1=require("bull"),_applogger=require("../logger/app.logger");function _ts_decorate(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}function _ts_metadata(k,v){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(k,v)}let AppQueue=class AppQueue{logger=new _applogger.AppLogger(this.constructor.name);constructor(){this.logger.log(this.constructor.name+" is ready")}onProgress(job){this.logger.log(`Job ${job.id} in ${job.name} is active`,job.data)}onCompleted(job){this.logger.log(`Job ${job.id} in ${job.name} is completed`,job.data)}onStalled(job){this.logger.error(`Job ${job.id} in ${job.name} is stalled`,job.data)}onError(job){this.logger.error(`Job ${job.id} in ${job.name} is error`,job.data)}onFailed(job,error){this.logger.error(`Job ${job.id} in ${job.name} is failed`,job.data,error)}};_ts_decorate([(0,_bull.OnQueueProgress)(),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",void 0)],AppQueue.prototype,"onProgress",null),_ts_decorate([(0,_bull.OnQueueCompleted)(),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",void 0)],AppQueue.prototype,"onCompleted",null),_ts_decorate([(0,_bull.OnQueueStalled)(),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",void 0)],AppQueue.prototype,"onStalled",null),_ts_decorate([(0,_bull.OnQueueError)(),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job]),_ts_metadata("design:returntype",void 0)],AppQueue.prototype,"onError",null),_ts_decorate([(0,_bull.OnQueueFailed)(),_ts_metadata("design:type",Function),_ts_metadata("design:paramtypes",[void 0===_bull1.Job?Object:_bull1.Job,Object]),_ts_metadata("design:returntype",void 0)],AppQueue.prototype,"onFailed",null);
@@ -1,18 +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
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./app.queue"), exports);
18
- __exportStar(require("./queue.module"), exports);
1
+ "use strict";function _export_star(from,to){return Object.keys(from).forEach(function(k){"default"===k||Object.prototype.hasOwnProperty.call(to,k)||Object.defineProperty(to,k,{enumerable:!0,get:function(){return from[k]}})}),from}Object.defineProperty(exports,"__esModule",{value:!0}),_export_star(require("./app.queue"),exports),_export_star(require("./queue.module"),exports);
@@ -1,41 +1 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.QueueModule = void 0;
10
- const bullmq_1 = require("@nestjs/bullmq");
11
- const common_1 = require("@nestjs/common");
12
- const config_1 = require("../../config");
13
- let QueueModule = class QueueModule {
14
- };
15
- exports.QueueModule = QueueModule;
16
- exports.QueueModule = QueueModule = __decorate([
17
- (0, common_1.Global)(),
18
- (0, common_1.Module)({
19
- imports: [
20
- bullmq_1.BullModule.forRootAsync({
21
- useFactory: async () => ({
22
- prefix: config_1.APP_KEY + ':JOBS:',
23
- defaultJobOptions: {
24
- delay: 0,
25
- removeOnComplete: true,
26
- removeOnFail: false,
27
- backoff: { type: 'exponential', delay: 10 },
28
- attempts: 2,
29
- },
30
- connection: {
31
- host: config_1.REDIS_HOST,
32
- port: config_1.REDIS_PORT,
33
- db: config_1.REDIS_DB,
34
- password: config_1.REDIS_PASSWORD,
35
- tls: config_1.REDIS_TLS ? { ca: '' } : undefined,
36
- },
37
- }),
38
- }),
39
- ],
40
- })
41
- ], QueueModule);
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"QueueModule",{enumerable:!0,get:function(){return QueueModule}});let _bullmq=require("@nestjs/bullmq"),_common=require("@nestjs/common"),_config=require("../../config");let QueueModule=class QueueModule{};QueueModule=function(decorators,target,key,desc){var d,c=arguments.length,r=c<3?target:null===desc?desc=Object.getOwnPropertyDescriptor(target,key):desc;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r}([(0,_common.Global)(),(0,_common.Module)({imports:[_bullmq.BullModule.forRootAsync({useFactory:async()=>({prefix:_config.APP_KEY+":JOBS:",defaultJobOptions:{delay:0,removeOnComplete:!0,removeOnFail:!1,backoff:{type:"exponential",delay:10},attempts:2},connection:{host:_config.REDIS_HOST,port:_config.REDIS_PORT,db:_config.REDIS_DB,password:_config.REDIS_PASSWORD,tls:_config.REDIS_TLS?{ca:""}:void 0}})})]})],QueueModule);
@@ -1,71 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppServiceUnavailableException = exports.AppInternalServerErrorException = exports.AppGatewayTimeoutException = exports.AppBadGatewayException = exports.AppConflictException = exports.AppUnauthorizedException = exports.AppForbiddenException = exports.AppNotFoundException = exports.AppUnprocessableEntityException = exports.AppBadRequestException = void 0;
4
- const common_1 = require("@nestjs/common");
5
- class AppBadRequestException extends common_1.BadRequestException {
6
- constructor(err) {
7
- const errors = typeof err === 'string'
8
- ? { error: err }
9
- : Object.entries(err).reduce((acc, [key, value]) => ({ ...acc, [key]: value }), {});
10
- super({ statusCode: 400, message: 'Bad request', errors });
11
- this.message = (typeof err === 'string' ? [err] : Object.values(err).flat()).join(', ');
12
- }
13
- has(str) {
14
- return this.message.includes(str);
15
- }
16
- }
17
- exports.AppBadRequestException = AppBadRequestException;
18
- class AppUnprocessableEntityException extends common_1.UnprocessableEntityException {
19
- constructor(message) {
20
- super({ statusCode: 422, message: message || 'Unprocessable entity' });
21
- }
22
- }
23
- exports.AppUnprocessableEntityException = AppUnprocessableEntityException;
24
- class AppNotFoundException extends common_1.NotFoundException {
25
- constructor(message) {
26
- super({ statusCode: 404, message: message || 'Not found' });
27
- }
28
- }
29
- exports.AppNotFoundException = AppNotFoundException;
30
- class AppForbiddenException extends common_1.ForbiddenException {
31
- constructor(message) {
32
- super({ statusCode: 403, message: message || 'Forbidden' });
33
- }
34
- }
35
- exports.AppForbiddenException = AppForbiddenException;
36
- class AppUnauthorizedException extends common_1.UnauthorizedException {
37
- constructor(message) {
38
- super({ statusCode: 401, message: message || 'Unauthorized' });
39
- }
40
- }
41
- exports.AppUnauthorizedException = AppUnauthorizedException;
42
- class AppConflictException extends common_1.ConflictException {
43
- constructor(message) {
44
- super({ statusCode: 409, message: message || 'Conflict' });
45
- }
46
- }
47
- exports.AppConflictException = AppConflictException;
48
- class AppBadGatewayException extends common_1.BadGatewayException {
49
- constructor(message) {
50
- super({ statusCode: 502, message: message || 'Bad gateway' });
51
- }
52
- }
53
- exports.AppBadGatewayException = AppBadGatewayException;
54
- class AppGatewayTimeoutException extends common_1.GatewayTimeoutException {
55
- constructor(message) {
56
- super({ statusCode: 504, message: message || 'Gateway timeout' });
57
- }
58
- }
59
- exports.AppGatewayTimeoutException = AppGatewayTimeoutException;
60
- class AppInternalServerErrorException extends common_1.InternalServerErrorException {
61
- constructor(message) {
62
- super({ statusCode: 500, message: message || 'Internal server error' });
63
- }
64
- }
65
- exports.AppInternalServerErrorException = AppInternalServerErrorException;
66
- class AppServiceUnavailableException extends common_1.ServiceUnavailableException {
67
- constructor(message) {
68
- super({ statusCode: 503, message: message || 'Service unavailable' });
69
- }
70
- }
71
- exports.AppServiceUnavailableException = AppServiceUnavailableException;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var target=exports,all={get AppBadGatewayException(){return AppBadGatewayException},get AppBadRequestException(){return AppBadRequestException},get AppConflictException(){return AppConflictException},get AppForbiddenException(){return AppForbiddenException},get AppGatewayTimeoutException(){return AppGatewayTimeoutException},get AppInternalServerErrorException(){return AppInternalServerErrorException},get AppNotFoundException(){return AppNotFoundException},get AppServiceUnavailableException(){return AppServiceUnavailableException},get AppUnauthorizedException(){return AppUnauthorizedException},get AppUnprocessableEntityException(){return AppUnprocessableEntityException}};for(var name in all)Object.defineProperty(target,name,{enumerable:!0,get:Object.getOwnPropertyDescriptor(all,name).get});let _common=require("@nestjs/common");let AppBadRequestException=class AppBadRequestException extends _common.BadRequestException{constructor(err){super({statusCode:400,message:"Bad request",errors:"string"==typeof err?{error:err}:Object.entries(err).reduce((acc,[key,value])=>({...acc,[key]:value}),{})}),this.message=("string"==typeof err?[err]:Object.values(err).flat()).join(", ")}has(str){return this.message.includes(str)}};let AppUnprocessableEntityException=class AppUnprocessableEntityException extends _common.UnprocessableEntityException{constructor(message){super({statusCode:422,message:message||"Unprocessable entity"})}};let AppNotFoundException=class AppNotFoundException extends _common.NotFoundException{constructor(message){super({statusCode:404,message:message||"Not found"})}};let AppForbiddenException=class AppForbiddenException extends _common.ForbiddenException{constructor(message){super({statusCode:403,message:message||"Forbidden"})}};let AppUnauthorizedException=class AppUnauthorizedException extends _common.UnauthorizedException{constructor(message){super({statusCode:401,message:message||"Unauthorized"})}};let AppConflictException=class AppConflictException extends _common.ConflictException{constructor(message){super({statusCode:409,message:message||"Conflict"})}};let AppBadGatewayException=class AppBadGatewayException extends _common.BadGatewayException{constructor(message){super({statusCode:502,message:message||"Bad gateway"})}};let AppGatewayTimeoutException=class AppGatewayTimeoutException extends _common.GatewayTimeoutException{constructor(message){super({statusCode:504,message:message||"Gateway timeout"})}};let AppInternalServerErrorException=class AppInternalServerErrorException extends _common.InternalServerErrorException{constructor(message){super({statusCode:500,message:message||"Internal server error"})}};let AppServiceUnavailableException=class AppServiceUnavailableException extends _common.ServiceUnavailableException{constructor(message){super({statusCode:503,message:message||"Service unavailable"})}};