@viardex/viardex-libs 1.0.12 → 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.
- package/README.md +12 -235
- package/dist/cache/{index.mjs → index.cjs} +48 -12
- package/dist/cache/index.cjs.map +1 -0
- package/dist/cache/{index.d.mts → index.d.cts} +1 -1
- package/dist/cache/index.d.ts +1 -1
- package/dist/cache/index.js +11 -47
- package/dist/cache/index.js.map +1 -1
- package/dist/common/{index.mjs → index.cjs} +159 -54
- package/dist/common/index.cjs.map +1 -0
- package/dist/common/{index.d.mts → index.d.cts} +0 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +53 -158
- package/dist/common/index.js.map +1 -1
- package/dist/{index.mjs → index.cjs} +242 -108
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +5 -6
- package/dist/index.d.ts +0 -1
- package/dist/index.js +107 -241
- package/dist/index.js.map +1 -1
- package/dist/logger/{index.mjs → index.cjs} +52 -26
- package/dist/logger/index.cjs.map +1 -0
- package/dist/logger/index.js +25 -51
- package/dist/logger/index.js.map +1 -1
- package/dist/nats/{index.mjs → index.cjs} +63 -18
- package/dist/nats/index.cjs.map +1 -0
- package/dist/nats/index.js +17 -62
- package/dist/nats/index.js.map +1 -1
- package/dist/rpc/{index.mjs → index.cjs} +32 -10
- package/dist/rpc/{index.mjs.map → index.cjs.map} +1 -1
- package/dist/rpc/index.js +9 -31
- package/dist/rpc/index.js.map +1 -1
- package/package.json +14 -13
- package/dist/cache/index.mjs.map +0 -1
- package/dist/common/index.mjs.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/logger/index.mjs.map +0 -1
- package/dist/nats/index.mjs.map +0 -1
- /package/dist/logger/{index.d.mts → index.d.cts} +0 -0
- /package/dist/nats/{index.d.mts → index.d.cts} +0 -0
- /package/dist/rpc/{index.d.mts → index.d.cts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,138 +1,5 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
AppResponse: () => AppResponse,
|
|
34
|
-
AuditSubjects: () => AuditSubjects,
|
|
35
|
-
BANKING_QUEUE: () => BANKING_QUEUE,
|
|
36
|
-
CACHE_MODULE_OPTIONS: () => CACHE_MODULE_OPTIONS,
|
|
37
|
-
CARD_QUEUE: () => CARD_QUEUE,
|
|
38
|
-
CRYPTO_QUEUE: () => CRYPTO_QUEUE,
|
|
39
|
-
CacheModule: () => CacheModule,
|
|
40
|
-
CacheService: () => CacheService,
|
|
41
|
-
CountrySubjects: () => CountrySubjects,
|
|
42
|
-
DEFAULT_NATS_CONFIG: () => DEFAULT_NATS_CONFIG,
|
|
43
|
-
DEFAULT_OTP_EXPIRY: () => DEFAULT_OTP_EXPIRY,
|
|
44
|
-
DEFAULT_OTP_LENGTH: () => DEFAULT_OTP_LENGTH,
|
|
45
|
-
DEFAULT_OTP_OPTIONS: () => DEFAULT_OTP_OPTIONS,
|
|
46
|
-
DeviceSubjects: () => DeviceSubjects,
|
|
47
|
-
FileValidationPipe: () => FileValidationPipe,
|
|
48
|
-
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
49
|
-
HttpOnlyExceptionFilter: () => HttpOnlyExceptionFilter,
|
|
50
|
-
KYC_QUEUE: () => KYC_QUEUE,
|
|
51
|
-
LEDGER_QUEUE: () => LEDGER_QUEUE,
|
|
52
|
-
LoggerModule: () => LoggerModule,
|
|
53
|
-
LoggingInterceptor: () => LoggingInterceptor,
|
|
54
|
-
MAX_OTP_ATTEMPTS: () => MAX_OTP_ATTEMPTS,
|
|
55
|
-
NATS_CLIENT: () => NATS_CLIENT,
|
|
56
|
-
NATS_EVENT_METADATA: () => NATS_EVENT_METADATA,
|
|
57
|
-
NATS_OPTIONS: () => NATS_OPTIONS,
|
|
58
|
-
NOTIFICATION_QUEUE: () => NOTIFICATION_QUEUE,
|
|
59
|
-
NatsEventPattern: () => NatsEventPattern,
|
|
60
|
-
NatsLoggingInterceptor: () => NatsLoggingInterceptor,
|
|
61
|
-
NatsMessageDto: () => NatsMessageDto,
|
|
62
|
-
NatsSubjects: () => NatsSubjects,
|
|
63
|
-
NotificationSubjects: () => NotificationSubjects,
|
|
64
|
-
OPS_QUEUE: () => OPS_QUEUE,
|
|
65
|
-
OTP_ATTEMPTS_CACHE_PREFIX: () => OTP_ATTEMPTS_CACHE_PREFIX,
|
|
66
|
-
OTP_BLOCK_DURATION: () => OTP_BLOCK_DURATION,
|
|
67
|
-
OTP_CACHE_PREFIX: () => OTP_CACHE_PREFIX,
|
|
68
|
-
OtpPurpose: () => OtpPurpose,
|
|
69
|
-
PaginationQueryCleanerPipe: () => PaginationQueryCleanerPipe,
|
|
70
|
-
PaginationQueryDto: () => PaginationQueryDto,
|
|
71
|
-
PasswordSubjects: () => PasswordSubjects,
|
|
72
|
-
PinSubjects: () => PinSubjects,
|
|
73
|
-
PinoLogger: () => import_nestjs_pino3.PinoLogger,
|
|
74
|
-
PreferencesSubjects: () => PreferencesSubjects,
|
|
75
|
-
ReferralSubjects: () => ReferralSubjects,
|
|
76
|
-
ResponseInterceptor: () => ResponseInterceptor,
|
|
77
|
-
RoleSubjects: () => RoleSubjects,
|
|
78
|
-
SigninSubjects: () => SigninSubjects,
|
|
79
|
-
SignupSubjects: () => SignupSubjects,
|
|
80
|
-
StaffSubjects: () => StaffSubjects,
|
|
81
|
-
TicketSubjects: () => TicketSubjects,
|
|
82
|
-
USER_QUEUE: () => USER_QUEUE,
|
|
83
|
-
UserServiceSubjects: () => UserServiceSubjects,
|
|
84
|
-
VAS_QUEUE: () => VAS_QUEUE,
|
|
85
|
-
ViardexRpc: () => ViardexRpc,
|
|
86
|
-
calculateNextDate: () => calculateNextDate,
|
|
87
|
-
countryDialCodes: () => countryDialCodes,
|
|
88
|
-
extractBin: () => extractBin,
|
|
89
|
-
extractLast4: () => extractLast4,
|
|
90
|
-
formatAccountNumber: () => formatAccountNumber,
|
|
91
|
-
formatAmount: () => formatAmount,
|
|
92
|
-
formatCardExpiry: () => formatCardExpiry,
|
|
93
|
-
formatCardLabel: () => formatCardLabel,
|
|
94
|
-
formatCryptoAmount: () => formatCryptoAmount,
|
|
95
|
-
formatCurrency: () => formatCurrency,
|
|
96
|
-
formatDate: () => formatDate,
|
|
97
|
-
formatDateTime: () => formatDateTime,
|
|
98
|
-
formatFileSize: () => formatFileSize,
|
|
99
|
-
formatPercentage: () => formatPercentage,
|
|
100
|
-
formatPhoneNumber: () => formatPhoneNumber,
|
|
101
|
-
formatRelativeTime: () => formatRelativeTime,
|
|
102
|
-
fromAtomicUnits: () => fromAtomicUnits,
|
|
103
|
-
generateRandomString: () => generateRandomString,
|
|
104
|
-
generateReference: () => generateReference,
|
|
105
|
-
getNatsConfig: () => getNatsConfig,
|
|
106
|
-
getNatsMicroserviceConfig: () => getNatsMicroserviceConfig,
|
|
107
|
-
getNatsServers: () => getNatsServers,
|
|
108
|
-
isDateInRange: () => isDateInRange,
|
|
109
|
-
isHexTxHash: () => isHexTxHash,
|
|
110
|
-
isNotPastDate: () => isNotPastDate,
|
|
111
|
-
isPositiveAmount: () => isPositiveAmount,
|
|
112
|
-
isStrongPassword: () => isStrongPassword,
|
|
113
|
-
isToday: () => isToday,
|
|
114
|
-
isValidAccountNumber: () => isValidAccountNumber,
|
|
115
|
-
isValidAge: () => isValidAge,
|
|
116
|
-
isValidAmount: () => isValidAmount,
|
|
117
|
-
isValidBVN: () => isValidBVN,
|
|
118
|
-
isValidEmail: () => isValidEmail,
|
|
119
|
-
isValidNIN: () => isValidNIN,
|
|
120
|
-
isValidNigerianPhone: () => isValidNigerianPhone,
|
|
121
|
-
isValidTransactionReference: () => isValidTransactionReference,
|
|
122
|
-
maskAccountNumber: () => maskAccountNumber,
|
|
123
|
-
maskEmail: () => maskEmail,
|
|
124
|
-
maskPan: () => maskPan,
|
|
125
|
-
maskPhoneNumber: () => maskPhoneNumber,
|
|
126
|
-
normalizeCardExpiry: () => normalizeCardExpiry,
|
|
127
|
-
normalizeNigerianPhone: () => normalizeNigerianPhone,
|
|
128
|
-
normalizeTxHash: () => normalizeTxHash,
|
|
129
|
-
toAtomicUnits: () => toAtomicUnits,
|
|
130
|
-
toDecimal: () => toDecimal,
|
|
131
|
-
toRoundedNumber: () => toRoundedNumber,
|
|
132
|
-
toTitleCase: () => toTitleCase,
|
|
133
|
-
truncateText: () => truncateText
|
|
134
|
-
});
|
|
135
|
-
module.exports = __toCommonJS(src_exports);
|
|
136
3
|
|
|
137
4
|
// src/nats/constants/nats.constants.ts
|
|
138
5
|
var NATS_OPTIONS = "NATS_OPTIONS";
|
|
@@ -235,7 +102,7 @@ var NatsSubjects = {
|
|
|
235
102
|
};
|
|
236
103
|
|
|
237
104
|
// src/nats/dto/nats-message.dto.ts
|
|
238
|
-
|
|
105
|
+
import { IsNotEmpty, IsOptional, IsString } from "class-validator";
|
|
239
106
|
function _ts_decorate(decorators, target, key, desc) {
|
|
240
107
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
241
108
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -265,27 +132,27 @@ var NatsMessageDto = class {
|
|
|
265
132
|
replyTo;
|
|
266
133
|
};
|
|
267
134
|
_ts_decorate([
|
|
268
|
-
|
|
269
|
-
|
|
135
|
+
IsString(),
|
|
136
|
+
IsNotEmpty(),
|
|
270
137
|
_ts_metadata("design:type", String)
|
|
271
138
|
], NatsMessageDto.prototype, "pattern", void 0);
|
|
272
139
|
_ts_decorate([
|
|
273
|
-
|
|
140
|
+
IsNotEmpty(),
|
|
274
141
|
_ts_metadata("design:type", Object)
|
|
275
142
|
], NatsMessageDto.prototype, "data", void 0);
|
|
276
143
|
_ts_decorate([
|
|
277
|
-
|
|
278
|
-
|
|
144
|
+
IsString(),
|
|
145
|
+
IsOptional(),
|
|
279
146
|
_ts_metadata("design:type", String)
|
|
280
147
|
], NatsMessageDto.prototype, "replyTo", void 0);
|
|
281
148
|
|
|
282
149
|
// src/nats/decorators/nats-event-pattern.decorator.ts
|
|
283
|
-
|
|
284
|
-
|
|
150
|
+
import { applyDecorators, SetMetadata, UseInterceptors } from "@nestjs/common";
|
|
151
|
+
import { EventPattern } from "@nestjs/microservices";
|
|
285
152
|
|
|
286
153
|
// src/nats/interceptors/nats-logging.interceptor.ts
|
|
287
|
-
|
|
288
|
-
|
|
154
|
+
import { Injectable, Logger } from "@nestjs/common";
|
|
155
|
+
import { tap } from "rxjs";
|
|
289
156
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
290
157
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
291
158
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -304,13 +171,13 @@ var NatsLoggingInterceptor = class _NatsLoggingInterceptor {
|
|
|
304
171
|
static {
|
|
305
172
|
__name(this, "NatsLoggingInterceptor");
|
|
306
173
|
}
|
|
307
|
-
logger = new
|
|
174
|
+
logger = new Logger(_NatsLoggingInterceptor.name);
|
|
308
175
|
intercept(context, next) {
|
|
309
176
|
const now = Date.now();
|
|
310
177
|
const rpcContext = context.switchToRpc();
|
|
311
178
|
const natsContext = rpcContext.getContext();
|
|
312
179
|
const pattern = natsContext.getSubject();
|
|
313
|
-
return next.handle().pipe(
|
|
180
|
+
return next.handle().pipe(tap({
|
|
314
181
|
next: /* @__PURE__ */ __name((data) => {
|
|
315
182
|
this.logger.log(`Pattern: ${pattern} | Response time: ${Date.now() - now}ms | Response: ${JSON.stringify(data)}`);
|
|
316
183
|
}, "next"),
|
|
@@ -321,15 +188,15 @@ var NatsLoggingInterceptor = class _NatsLoggingInterceptor {
|
|
|
321
188
|
}
|
|
322
189
|
};
|
|
323
190
|
NatsLoggingInterceptor = _ts_decorate2([
|
|
324
|
-
|
|
191
|
+
Injectable()
|
|
325
192
|
], NatsLoggingInterceptor);
|
|
326
193
|
|
|
327
194
|
// src/nats/decorators/nats-event-pattern.decorator.ts
|
|
328
195
|
var NATS_EVENT_METADATA = "nats_event_metadata";
|
|
329
196
|
function NatsEventPattern(pattern) {
|
|
330
|
-
return
|
|
197
|
+
return applyDecorators(SetMetadata(NATS_EVENT_METADATA, {
|
|
331
198
|
pattern
|
|
332
|
-
}),
|
|
199
|
+
}), EventPattern(pattern), UseInterceptors(NatsLoggingInterceptor));
|
|
333
200
|
}
|
|
334
201
|
__name(NatsEventPattern, "NatsEventPattern");
|
|
335
202
|
|
|
@@ -406,16 +273,16 @@ var formatCardLabel = /* @__PURE__ */ __name((brand, last4) => {
|
|
|
406
273
|
}, "formatCardLabel");
|
|
407
274
|
|
|
408
275
|
// src/common/crypto/crypto.utils.ts
|
|
409
|
-
|
|
410
|
-
var DECIMAL_ZERO = new
|
|
276
|
+
import Decimal from "decimal.js";
|
|
277
|
+
var DECIMAL_ZERO = new Decimal(0);
|
|
411
278
|
var toAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
412
|
-
return new
|
|
279
|
+
return new Decimal(value).mul(new Decimal(10).pow(decimals)).toDecimalPlaces(0, Decimal.ROUND_DOWN).toFixed(0);
|
|
413
280
|
}, "toAtomicUnits");
|
|
414
281
|
var fromAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
415
|
-
return new
|
|
282
|
+
return new Decimal(value).div(new Decimal(10).pow(decimals)).toFixed();
|
|
416
283
|
}, "fromAtomicUnits");
|
|
417
284
|
var formatCryptoAmount = /* @__PURE__ */ __name((value, decimals = 8) => {
|
|
418
|
-
return new
|
|
285
|
+
return new Decimal(value).toDecimalPlaces(decimals).toString();
|
|
419
286
|
}, "formatCryptoAmount");
|
|
420
287
|
var normalizeTxHash = /* @__PURE__ */ __name((hash) => {
|
|
421
288
|
return hash.trim().toLowerCase();
|
|
@@ -431,7 +298,7 @@ var isHexTxHash = /* @__PURE__ */ __name((hash, expectedLength) => {
|
|
|
431
298
|
return true;
|
|
432
299
|
}, "isHexTxHash");
|
|
433
300
|
var isPositiveAmount = /* @__PURE__ */ __name((value) => {
|
|
434
|
-
return new
|
|
301
|
+
return new Decimal(value).greaterThan(DECIMAL_ZERO);
|
|
435
302
|
}, "isPositiveAmount");
|
|
436
303
|
|
|
437
304
|
// src/common/enums/otp.enum.ts
|
|
@@ -454,8 +321,8 @@ var OtpPurpose = /* @__PURE__ */ (function(OtpPurpose2) {
|
|
|
454
321
|
})({});
|
|
455
322
|
|
|
456
323
|
// src/common/dto/pagination-query.dto.ts
|
|
457
|
-
|
|
458
|
-
|
|
324
|
+
import { Type } from "class-transformer";
|
|
325
|
+
import { IsIn, IsInt, IsOptional as IsOptional2, IsString as IsString2, Min } from "class-validator";
|
|
459
326
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
460
327
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
461
328
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -487,40 +354,40 @@ var PaginationQueryDto = class {
|
|
|
487
354
|
sortOrder;
|
|
488
355
|
};
|
|
489
356
|
_ts_decorate3([
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
(
|
|
357
|
+
Type(() => Number),
|
|
358
|
+
IsInt(),
|
|
359
|
+
Min(1),
|
|
360
|
+
IsOptional2(),
|
|
494
361
|
_ts_metadata2("design:type", Number)
|
|
495
362
|
], PaginationQueryDto.prototype, "page", void 0);
|
|
496
363
|
_ts_decorate3([
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
(
|
|
364
|
+
Type(() => Number),
|
|
365
|
+
IsInt(),
|
|
366
|
+
Min(1),
|
|
367
|
+
IsOptional2(),
|
|
501
368
|
_ts_metadata2("design:type", Number)
|
|
502
369
|
], PaginationQueryDto.prototype, "limit", void 0);
|
|
503
370
|
_ts_decorate3([
|
|
504
|
-
(
|
|
505
|
-
(
|
|
371
|
+
IsString2(),
|
|
372
|
+
IsOptional2(),
|
|
506
373
|
_ts_metadata2("design:type", String)
|
|
507
374
|
], PaginationQueryDto.prototype, "search", void 0);
|
|
508
375
|
_ts_decorate3([
|
|
509
|
-
(
|
|
510
|
-
(
|
|
376
|
+
IsString2(),
|
|
377
|
+
IsOptional2(),
|
|
511
378
|
_ts_metadata2("design:type", String)
|
|
512
379
|
], PaginationQueryDto.prototype, "sortBy", void 0);
|
|
513
380
|
_ts_decorate3([
|
|
514
|
-
|
|
381
|
+
IsIn([
|
|
515
382
|
"asc",
|
|
516
383
|
"desc"
|
|
517
384
|
]),
|
|
518
|
-
(
|
|
385
|
+
IsOptional2(),
|
|
519
386
|
_ts_metadata2("design:type", String)
|
|
520
387
|
], PaginationQueryDto.prototype, "sortOrder", void 0);
|
|
521
388
|
|
|
522
389
|
// src/common/pipes/file-validation.pipe.ts
|
|
523
|
-
|
|
390
|
+
import { BadRequestException, Injectable as Injectable2 } from "@nestjs/common";
|
|
524
391
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
525
392
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
526
393
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -558,7 +425,7 @@ var FileValidationPipe = class {
|
|
|
558
425
|
transform(value) {
|
|
559
426
|
const files = this.normalizeFiles(value);
|
|
560
427
|
if (files.length === 0) {
|
|
561
|
-
throw new
|
|
428
|
+
throw new BadRequestException("No files uploaded");
|
|
562
429
|
}
|
|
563
430
|
this.validateRequiredFields(value);
|
|
564
431
|
const allowedMimeTypes = this.options.allowedMimeTypes ?? DEFAULT_ALLOWED_MIME_TYPES;
|
|
@@ -566,10 +433,10 @@ var FileValidationPipe = class {
|
|
|
566
433
|
for (const file of files) {
|
|
567
434
|
const label = file.fieldname || file.originalname || "file";
|
|
568
435
|
if (file.mimetype && !allowedMimeTypes.includes(file.mimetype)) {
|
|
569
|
-
throw new
|
|
436
|
+
throw new BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
|
|
570
437
|
}
|
|
571
438
|
if (typeof file.size === "number" && file.size > maxSizeBytes) {
|
|
572
|
-
throw new
|
|
439
|
+
throw new BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
|
|
573
440
|
}
|
|
574
441
|
}
|
|
575
442
|
return value;
|
|
@@ -582,7 +449,7 @@ var FileValidationPipe = class {
|
|
|
582
449
|
for (const field of requiredFields) {
|
|
583
450
|
const files = value[field];
|
|
584
451
|
if (!files || files.length === 0) {
|
|
585
|
-
throw new
|
|
452
|
+
throw new BadRequestException(`${field} file is required`);
|
|
586
453
|
}
|
|
587
454
|
}
|
|
588
455
|
}
|
|
@@ -606,7 +473,7 @@ var FileValidationPipe = class {
|
|
|
606
473
|
}
|
|
607
474
|
};
|
|
608
475
|
FileValidationPipe = _ts_decorate4([
|
|
609
|
-
(
|
|
476
|
+
Injectable2(),
|
|
610
477
|
_ts_metadata3("design:type", Function),
|
|
611
478
|
_ts_metadata3("design:paramtypes", [
|
|
612
479
|
typeof FileValidationOptions === "undefined" ? Object : FileValidationOptions
|
|
@@ -614,7 +481,7 @@ FileValidationPipe = _ts_decorate4([
|
|
|
614
481
|
], FileValidationPipe);
|
|
615
482
|
|
|
616
483
|
// src/common/pipes/pagination-query-cleaner.pipe.ts
|
|
617
|
-
|
|
484
|
+
import { Injectable as Injectable3 } from "@nestjs/common";
|
|
618
485
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
619
486
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
620
487
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -643,11 +510,11 @@ var PaginationQueryCleanerPipe = class {
|
|
|
643
510
|
}
|
|
644
511
|
};
|
|
645
512
|
PaginationQueryCleanerPipe = _ts_decorate5([
|
|
646
|
-
(
|
|
513
|
+
Injectable3()
|
|
647
514
|
], PaginationQueryCleanerPipe);
|
|
648
515
|
|
|
649
516
|
// src/common/response/http-exception.filter.ts
|
|
650
|
-
|
|
517
|
+
import { BadRequestException as BadRequestException2, Catch, HttpException, HttpStatus, Logger as Logger2 } from "@nestjs/common";
|
|
651
518
|
|
|
652
519
|
// src/common/response/response.utils.ts
|
|
653
520
|
var AppResponse = class {
|
|
@@ -709,13 +576,13 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
709
576
|
static {
|
|
710
577
|
__name(this, "HttpExceptionFilter");
|
|
711
578
|
}
|
|
712
|
-
logger = new
|
|
579
|
+
logger = new Logger2(_HttpExceptionFilter.name);
|
|
713
580
|
catch(exception, host) {
|
|
714
581
|
const ctx = host.switchToHttp();
|
|
715
582
|
const response = ctx.getResponse();
|
|
716
583
|
const request = ctx.getRequest();
|
|
717
|
-
const status = exception instanceof
|
|
718
|
-
const message = exception instanceof
|
|
584
|
+
const status = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
|
|
585
|
+
const message = exception instanceof HttpException ? exception.message : "An unexpected error occurred";
|
|
719
586
|
const errors = this.getValidationErrors(exception);
|
|
720
587
|
this.logger.error({
|
|
721
588
|
method: request.method,
|
|
@@ -732,7 +599,7 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
732
599
|
response.status(status).send(body);
|
|
733
600
|
}
|
|
734
601
|
getValidationErrors(exception) {
|
|
735
|
-
if (!(exception instanceof
|
|
602
|
+
if (!(exception instanceof BadRequestException2)) {
|
|
736
603
|
return void 0;
|
|
737
604
|
}
|
|
738
605
|
const payload = exception.getResponse();
|
|
@@ -752,11 +619,11 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
752
619
|
}
|
|
753
620
|
};
|
|
754
621
|
HttpExceptionFilter = _ts_decorate6([
|
|
755
|
-
|
|
622
|
+
Catch()
|
|
756
623
|
], HttpExceptionFilter);
|
|
757
624
|
|
|
758
625
|
// src/common/response/http-only-exception.filter.ts
|
|
759
|
-
|
|
626
|
+
import { Catch as Catch2 } from "@nestjs/common";
|
|
760
627
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
761
628
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
762
629
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -784,12 +651,12 @@ var HttpOnlyExceptionFilter = class {
|
|
|
784
651
|
}
|
|
785
652
|
};
|
|
786
653
|
HttpOnlyExceptionFilter = _ts_decorate7([
|
|
787
|
-
(
|
|
654
|
+
Catch2()
|
|
788
655
|
], HttpOnlyExceptionFilter);
|
|
789
656
|
|
|
790
657
|
// src/common/response/response.interceptor.ts
|
|
791
|
-
|
|
792
|
-
|
|
658
|
+
import { Injectable as Injectable4 } from "@nestjs/common";
|
|
659
|
+
import { map } from "rxjs/operators";
|
|
793
660
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
794
661
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
795
662
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -821,7 +688,7 @@ var ResponseInterceptor = class {
|
|
|
821
688
|
return next.handle();
|
|
822
689
|
}
|
|
823
690
|
const request = context.switchToHttp().getRequest();
|
|
824
|
-
return next.handle().pipe(
|
|
691
|
+
return next.handle().pipe(map((data) => {
|
|
825
692
|
if (isApiResponse(data)) {
|
|
826
693
|
return data;
|
|
827
694
|
}
|
|
@@ -841,11 +708,11 @@ var ResponseInterceptor = class {
|
|
|
841
708
|
}
|
|
842
709
|
};
|
|
843
710
|
ResponseInterceptor = _ts_decorate8([
|
|
844
|
-
(
|
|
711
|
+
Injectable4()
|
|
845
712
|
], ResponseInterceptor);
|
|
846
713
|
|
|
847
714
|
// src/common/utils/country.utils.ts
|
|
848
|
-
|
|
715
|
+
import * as CountryCodeList from "country-codes-list";
|
|
849
716
|
var countryDialCodes = Object.keys(CountryCodeList.customList("countryCallingCode")).map((code) => `+${code}`);
|
|
850
717
|
|
|
851
718
|
// src/common/utils/date.utils.ts
|
|
@@ -887,15 +754,15 @@ var isValidAge = /* @__PURE__ */ __name((dateOfBirth, minAge = 18) => {
|
|
|
887
754
|
}, "isValidAge");
|
|
888
755
|
|
|
889
756
|
// src/common/utils/decimal.utils.ts
|
|
890
|
-
|
|
757
|
+
import Decimal2 from "decimal.js";
|
|
891
758
|
var DEFAULT_DECIMAL_PLACES = 4;
|
|
892
|
-
|
|
759
|
+
Decimal2.set({
|
|
893
760
|
precision: 20,
|
|
894
|
-
rounding:
|
|
761
|
+
rounding: Decimal2.ROUND_HALF_UP
|
|
895
762
|
});
|
|
896
763
|
var toDecimal = /* @__PURE__ */ __name((value) => {
|
|
897
764
|
try {
|
|
898
|
-
return new
|
|
765
|
+
return new Decimal2(value);
|
|
899
766
|
} catch {
|
|
900
767
|
throw new Error(`Invalid decimal value: ${value}`);
|
|
901
768
|
}
|
|
@@ -1106,13 +973,13 @@ var isValidTransactionReference = /* @__PURE__ */ __name((reference) => {
|
|
|
1106
973
|
}, "isValidTransactionReference");
|
|
1107
974
|
|
|
1108
975
|
// src/common/config/nats.config.ts
|
|
1109
|
-
|
|
976
|
+
import { Transport } from "@nestjs/microservices";
|
|
1110
977
|
var getNatsServers = /* @__PURE__ */ __name((configService) => {
|
|
1111
|
-
const rawServers = configService.get("
|
|
978
|
+
const rawServers = configService.get("NATS_URL") ?? "nats://localhost:4222";
|
|
1112
979
|
return rawServers.split(",").map((server) => server.trim()).filter(Boolean);
|
|
1113
980
|
}, "getNatsServers");
|
|
1114
981
|
var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
|
|
1115
|
-
transport:
|
|
982
|
+
transport: Transport.NATS,
|
|
1116
983
|
options: {
|
|
1117
984
|
servers: getNatsServers(configService)
|
|
1118
985
|
}
|
|
@@ -1120,7 +987,7 @@ var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
|
|
|
1120
987
|
var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
1121
988
|
const queue = queueName && configService.get(`NATS_${queueName.toUpperCase()}_QUEUE`);
|
|
1122
989
|
return {
|
|
1123
|
-
transport:
|
|
990
|
+
transport: Transport.NATS,
|
|
1124
991
|
options: {
|
|
1125
992
|
servers: getNatsServers(configService),
|
|
1126
993
|
...queue ? {
|
|
@@ -1134,12 +1001,12 @@ var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
|
1134
1001
|
var CACHE_MODULE_OPTIONS = /* @__PURE__ */ Symbol("CACHE_MODULE_OPTIONS");
|
|
1135
1002
|
|
|
1136
1003
|
// src/cache/cache.module.ts
|
|
1137
|
-
|
|
1138
|
-
|
|
1004
|
+
import { Module } from "@nestjs/common";
|
|
1005
|
+
import { ConfigModule } from "@nestjs/config";
|
|
1139
1006
|
|
|
1140
1007
|
// src/cache/cache.service.ts
|
|
1141
|
-
|
|
1142
|
-
|
|
1008
|
+
import { Inject, Injectable as Injectable5 } from "@nestjs/common";
|
|
1009
|
+
import Redis from "ioredis";
|
|
1143
1010
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1144
1011
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1145
1012
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1177,7 +1044,7 @@ var CacheService = class {
|
|
|
1177
1044
|
}
|
|
1178
1045
|
async onModuleInit() {
|
|
1179
1046
|
const options = this.options || {};
|
|
1180
|
-
this.redisClient = new
|
|
1047
|
+
this.redisClient = new Redis({
|
|
1181
1048
|
...options,
|
|
1182
1049
|
host: options.host || process.env.REDIS_HOST || "localhost",
|
|
1183
1050
|
port: options.port || +(process.env?.REDIS_PORT || 6379),
|
|
@@ -1265,8 +1132,8 @@ var CacheService = class {
|
|
|
1265
1132
|
}
|
|
1266
1133
|
};
|
|
1267
1134
|
CacheService = _ts_decorate9([
|
|
1268
|
-
(
|
|
1269
|
-
_ts_param(0,
|
|
1135
|
+
Injectable5(),
|
|
1136
|
+
_ts_param(0, Inject(CACHE_MODULE_OPTIONS)),
|
|
1270
1137
|
_ts_metadata4("design:type", Function),
|
|
1271
1138
|
_ts_metadata4("design:paramtypes", [
|
|
1272
1139
|
typeof CacheOptions === "undefined" ? Object : CacheOptions
|
|
@@ -1296,7 +1163,7 @@ var CacheModule = class _CacheModule {
|
|
|
1296
1163
|
return {
|
|
1297
1164
|
module: _CacheModule,
|
|
1298
1165
|
imports: [
|
|
1299
|
-
|
|
1166
|
+
ConfigModule
|
|
1300
1167
|
],
|
|
1301
1168
|
providers: [
|
|
1302
1169
|
CacheService,
|
|
@@ -1312,18 +1179,18 @@ var CacheModule = class _CacheModule {
|
|
|
1312
1179
|
}
|
|
1313
1180
|
};
|
|
1314
1181
|
CacheModule = _ts_decorate10([
|
|
1315
|
-
|
|
1182
|
+
Module({})
|
|
1316
1183
|
], CacheModule);
|
|
1317
1184
|
|
|
1318
1185
|
// src/rpc/index.ts
|
|
1319
|
-
|
|
1320
|
-
|
|
1186
|
+
import { BadRequestException as BadRequestException3, HttpException as HttpException2, Logger as Logger3 } from "@nestjs/common";
|
|
1187
|
+
import { RpcException } from "@nestjs/microservices";
|
|
1321
1188
|
var ViardexRpcUtils = class ViardexRpcUtils2 {
|
|
1322
1189
|
static {
|
|
1323
1190
|
__name(this, "ViardexRpcUtils");
|
|
1324
1191
|
}
|
|
1325
1192
|
static getValidationErrors(err) {
|
|
1326
|
-
if (err instanceof
|
|
1193
|
+
if (err instanceof BadRequestException3) {
|
|
1327
1194
|
const response = err.getResponse();
|
|
1328
1195
|
if (typeof response === "object" && response !== null && "errors" in response) {
|
|
1329
1196
|
return Array.isArray(response.errors) ? response.errors : [];
|
|
@@ -1353,7 +1220,7 @@ var ViardexRpc = class {
|
|
|
1353
1220
|
static catch(err, ctx) {
|
|
1354
1221
|
const subject = ctx ? ctx.getArgs()[0] : null;
|
|
1355
1222
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
1356
|
-
const statusCode = err instanceof
|
|
1223
|
+
const statusCode = err instanceof HttpException2 ? err.getStatus() : 500;
|
|
1357
1224
|
const errorDetails = {
|
|
1358
1225
|
success: false,
|
|
1359
1226
|
subject,
|
|
@@ -1361,7 +1228,7 @@ var ViardexRpc = class {
|
|
|
1361
1228
|
statusCode,
|
|
1362
1229
|
errors: ViardexRpcUtils.getValidationErrors(err)
|
|
1363
1230
|
};
|
|
1364
|
-
return new
|
|
1231
|
+
return new RpcException(errorDetails);
|
|
1365
1232
|
}
|
|
1366
1233
|
static async withReply(obs) {
|
|
1367
1234
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -1371,8 +1238,8 @@ var ViardexRpc = class {
|
|
|
1371
1238
|
});
|
|
1372
1239
|
});
|
|
1373
1240
|
if (ViardexRpcUtils.isErrorResponse(result)) {
|
|
1374
|
-
|
|
1375
|
-
throw new
|
|
1241
|
+
Logger3.error(result.error);
|
|
1242
|
+
throw new HttpException2(result.error, result.error.statusCode, {
|
|
1376
1243
|
cause: result.error.errors
|
|
1377
1244
|
});
|
|
1378
1245
|
}
|
|
@@ -1381,15 +1248,15 @@ var ViardexRpc = class {
|
|
|
1381
1248
|
};
|
|
1382
1249
|
|
|
1383
1250
|
// src/logger/logger.module.ts
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1251
|
+
import { Global, Logger as Logger4, Module as Module2 } from "@nestjs/common";
|
|
1252
|
+
import { ConfigModule as ConfigModule2, ConfigService } from "@nestjs/config";
|
|
1253
|
+
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
1254
|
+
import { LoggerModule as PinoLoggerModule, PinoLogger as PinoLogger2 } from "nestjs-pino";
|
|
1388
1255
|
|
|
1389
1256
|
// src/logger/logging.interceptor.ts
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1257
|
+
import { Inject as Inject2, Injectable as Injectable6 } from "@nestjs/common";
|
|
1258
|
+
import { tap as tap2 } from "rxjs";
|
|
1259
|
+
import { PinoLogger } from "nestjs-pino";
|
|
1393
1260
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
1394
1261
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1395
1262
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -1437,7 +1304,7 @@ var LoggingInterceptor = class {
|
|
|
1437
1304
|
method: request.method,
|
|
1438
1305
|
url: request.url
|
|
1439
1306
|
}, "Incoming request");
|
|
1440
|
-
return next.handle().pipe((
|
|
1307
|
+
return next.handle().pipe(tap2({
|
|
1441
1308
|
next: /* @__PURE__ */ __name(() => {
|
|
1442
1309
|
this.logger.info({
|
|
1443
1310
|
requestId,
|
|
@@ -1462,11 +1329,11 @@ var LoggingInterceptor = class {
|
|
|
1462
1329
|
}
|
|
1463
1330
|
};
|
|
1464
1331
|
LoggingInterceptor = _ts_decorate11([
|
|
1465
|
-
(
|
|
1466
|
-
_ts_param2(0, (
|
|
1332
|
+
Injectable6(),
|
|
1333
|
+
_ts_param2(0, Inject2(PinoLogger)),
|
|
1467
1334
|
_ts_metadata5("design:type", Function),
|
|
1468
1335
|
_ts_metadata5("design:paramtypes", [
|
|
1469
|
-
typeof
|
|
1336
|
+
typeof PinoLogger === "undefined" ? Object : PinoLogger
|
|
1470
1337
|
])
|
|
1471
1338
|
], LoggingInterceptor);
|
|
1472
1339
|
|
|
@@ -1491,15 +1358,15 @@ var LoggerModule = class {
|
|
|
1491
1358
|
}
|
|
1492
1359
|
};
|
|
1493
1360
|
LoggerModule = _ts_decorate12([
|
|
1494
|
-
|
|
1495
|
-
(
|
|
1361
|
+
Global(),
|
|
1362
|
+
Module2({
|
|
1496
1363
|
imports: [
|
|
1497
|
-
|
|
1364
|
+
PinoLoggerModule.forRootAsync({
|
|
1498
1365
|
imports: [
|
|
1499
|
-
|
|
1366
|
+
ConfigModule2
|
|
1500
1367
|
],
|
|
1501
1368
|
inject: [
|
|
1502
|
-
|
|
1369
|
+
ConfigService
|
|
1503
1370
|
],
|
|
1504
1371
|
useFactory: /* @__PURE__ */ __name((configService) => {
|
|
1505
1372
|
const env = configService.get("NODE_ENV", "development");
|
|
@@ -1536,26 +1403,25 @@ LoggerModule = _ts_decorate12([
|
|
|
1536
1403
|
providers: [
|
|
1537
1404
|
LoggingInterceptor,
|
|
1538
1405
|
{
|
|
1539
|
-
provide:
|
|
1406
|
+
provide: APP_INTERCEPTOR,
|
|
1540
1407
|
useExisting: LoggingInterceptor
|
|
1541
1408
|
},
|
|
1542
1409
|
{
|
|
1543
|
-
provide:
|
|
1544
|
-
useExisting:
|
|
1410
|
+
provide: Logger4,
|
|
1411
|
+
useExisting: PinoLogger2
|
|
1545
1412
|
}
|
|
1546
1413
|
],
|
|
1547
1414
|
exports: [
|
|
1548
|
-
|
|
1415
|
+
PinoLoggerModule,
|
|
1549
1416
|
LoggingInterceptor,
|
|
1550
|
-
|
|
1417
|
+
Logger4
|
|
1551
1418
|
]
|
|
1552
1419
|
})
|
|
1553
1420
|
], LoggerModule);
|
|
1554
1421
|
|
|
1555
1422
|
// src/logger/index.ts
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
0 && (module.exports = {
|
|
1423
|
+
import { PinoLogger as PinoLogger3 } from "nestjs-pino";
|
|
1424
|
+
export {
|
|
1559
1425
|
AppResponse,
|
|
1560
1426
|
AuditSubjects,
|
|
1561
1427
|
BANKING_QUEUE,
|
|
@@ -1596,7 +1462,7 @@ var import_nestjs_pino3 = require("nestjs-pino");
|
|
|
1596
1462
|
PaginationQueryDto,
|
|
1597
1463
|
PasswordSubjects,
|
|
1598
1464
|
PinSubjects,
|
|
1599
|
-
PinoLogger,
|
|
1465
|
+
PinoLogger3 as PinoLogger,
|
|
1600
1466
|
PreferencesSubjects,
|
|
1601
1467
|
ReferralSubjects,
|
|
1602
1468
|
ResponseInterceptor,
|
|
@@ -1657,5 +1523,5 @@ var import_nestjs_pino3 = require("nestjs-pino");
|
|
|
1657
1523
|
toRoundedNumber,
|
|
1658
1524
|
toTitleCase,
|
|
1659
1525
|
truncateText
|
|
1660
|
-
}
|
|
1526
|
+
};
|
|
1661
1527
|
//# sourceMappingURL=index.js.map
|