@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/common/index.js
CHANGED
|
@@ -1,109 +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/common/index.ts
|
|
31
|
-
var common_exports = {};
|
|
32
|
-
__export(common_exports, {
|
|
33
|
-
AppResponse: () => AppResponse,
|
|
34
|
-
BANKING_QUEUE: () => BANKING_QUEUE,
|
|
35
|
-
CARD_QUEUE: () => CARD_QUEUE,
|
|
36
|
-
CRYPTO_QUEUE: () => CRYPTO_QUEUE,
|
|
37
|
-
DEFAULT_OTP_EXPIRY: () => DEFAULT_OTP_EXPIRY,
|
|
38
|
-
DEFAULT_OTP_LENGTH: () => DEFAULT_OTP_LENGTH,
|
|
39
|
-
DEFAULT_OTP_OPTIONS: () => DEFAULT_OTP_OPTIONS,
|
|
40
|
-
FileValidationPipe: () => FileValidationPipe,
|
|
41
|
-
HttpExceptionFilter: () => HttpExceptionFilter,
|
|
42
|
-
HttpOnlyExceptionFilter: () => HttpOnlyExceptionFilter,
|
|
43
|
-
KYC_QUEUE: () => KYC_QUEUE,
|
|
44
|
-
LEDGER_QUEUE: () => LEDGER_QUEUE,
|
|
45
|
-
MAX_OTP_ATTEMPTS: () => MAX_OTP_ATTEMPTS,
|
|
46
|
-
NOTIFICATION_QUEUE: () => NOTIFICATION_QUEUE,
|
|
47
|
-
OPS_QUEUE: () => OPS_QUEUE,
|
|
48
|
-
OTP_ATTEMPTS_CACHE_PREFIX: () => OTP_ATTEMPTS_CACHE_PREFIX,
|
|
49
|
-
OTP_BLOCK_DURATION: () => OTP_BLOCK_DURATION,
|
|
50
|
-
OTP_CACHE_PREFIX: () => OTP_CACHE_PREFIX,
|
|
51
|
-
OtpPurpose: () => OtpPurpose,
|
|
52
|
-
PaginationQueryCleanerPipe: () => PaginationQueryCleanerPipe,
|
|
53
|
-
PaginationQueryDto: () => PaginationQueryDto,
|
|
54
|
-
ResponseInterceptor: () => ResponseInterceptor,
|
|
55
|
-
USER_QUEUE: () => USER_QUEUE,
|
|
56
|
-
VAS_QUEUE: () => VAS_QUEUE,
|
|
57
|
-
calculateNextDate: () => calculateNextDate,
|
|
58
|
-
countryDialCodes: () => countryDialCodes,
|
|
59
|
-
extractBin: () => extractBin,
|
|
60
|
-
extractLast4: () => extractLast4,
|
|
61
|
-
formatAccountNumber: () => formatAccountNumber,
|
|
62
|
-
formatAmount: () => formatAmount,
|
|
63
|
-
formatCardExpiry: () => formatCardExpiry,
|
|
64
|
-
formatCardLabel: () => formatCardLabel,
|
|
65
|
-
formatCryptoAmount: () => formatCryptoAmount,
|
|
66
|
-
formatCurrency: () => formatCurrency,
|
|
67
|
-
formatDate: () => formatDate,
|
|
68
|
-
formatDateTime: () => formatDateTime,
|
|
69
|
-
formatFileSize: () => formatFileSize,
|
|
70
|
-
formatPercentage: () => formatPercentage,
|
|
71
|
-
formatPhoneNumber: () => formatPhoneNumber,
|
|
72
|
-
formatRelativeTime: () => formatRelativeTime,
|
|
73
|
-
fromAtomicUnits: () => fromAtomicUnits,
|
|
74
|
-
generateRandomString: () => generateRandomString,
|
|
75
|
-
generateReference: () => generateReference,
|
|
76
|
-
getNatsConfig: () => getNatsConfig,
|
|
77
|
-
getNatsMicroserviceConfig: () => getNatsMicroserviceConfig,
|
|
78
|
-
getNatsServers: () => getNatsServers,
|
|
79
|
-
isDateInRange: () => isDateInRange,
|
|
80
|
-
isHexTxHash: () => isHexTxHash,
|
|
81
|
-
isNotPastDate: () => isNotPastDate,
|
|
82
|
-
isPositiveAmount: () => isPositiveAmount,
|
|
83
|
-
isStrongPassword: () => isStrongPassword,
|
|
84
|
-
isToday: () => isToday,
|
|
85
|
-
isValidAccountNumber: () => isValidAccountNumber,
|
|
86
|
-
isValidAge: () => isValidAge,
|
|
87
|
-
isValidAmount: () => isValidAmount,
|
|
88
|
-
isValidBVN: () => isValidBVN,
|
|
89
|
-
isValidEmail: () => isValidEmail,
|
|
90
|
-
isValidNIN: () => isValidNIN,
|
|
91
|
-
isValidNigerianPhone: () => isValidNigerianPhone,
|
|
92
|
-
isValidTransactionReference: () => isValidTransactionReference,
|
|
93
|
-
maskAccountNumber: () => maskAccountNumber,
|
|
94
|
-
maskEmail: () => maskEmail,
|
|
95
|
-
maskPan: () => maskPan,
|
|
96
|
-
maskPhoneNumber: () => maskPhoneNumber,
|
|
97
|
-
normalizeCardExpiry: () => normalizeCardExpiry,
|
|
98
|
-
normalizeNigerianPhone: () => normalizeNigerianPhone,
|
|
99
|
-
normalizeTxHash: () => normalizeTxHash,
|
|
100
|
-
toAtomicUnits: () => toAtomicUnits,
|
|
101
|
-
toDecimal: () => toDecimal,
|
|
102
|
-
toRoundedNumber: () => toRoundedNumber,
|
|
103
|
-
toTitleCase: () => toTitleCase,
|
|
104
|
-
truncateText: () => truncateText
|
|
105
|
-
});
|
|
106
|
-
module.exports = __toCommonJS(common_exports);
|
|
107
3
|
|
|
108
4
|
// src/common/constants/queues.constants.ts
|
|
109
5
|
var USER_QUEUE = "user_queue";
|
|
@@ -178,16 +74,16 @@ var formatCardLabel = /* @__PURE__ */ __name((brand, last4) => {
|
|
|
178
74
|
}, "formatCardLabel");
|
|
179
75
|
|
|
180
76
|
// src/common/crypto/crypto.utils.ts
|
|
181
|
-
|
|
182
|
-
var DECIMAL_ZERO = new
|
|
77
|
+
import Decimal from "decimal.js";
|
|
78
|
+
var DECIMAL_ZERO = new Decimal(0);
|
|
183
79
|
var toAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
184
|
-
return new
|
|
80
|
+
return new Decimal(value).mul(new Decimal(10).pow(decimals)).toDecimalPlaces(0, Decimal.ROUND_DOWN).toFixed(0);
|
|
185
81
|
}, "toAtomicUnits");
|
|
186
82
|
var fromAtomicUnits = /* @__PURE__ */ __name((value, decimals) => {
|
|
187
|
-
return new
|
|
83
|
+
return new Decimal(value).div(new Decimal(10).pow(decimals)).toFixed();
|
|
188
84
|
}, "fromAtomicUnits");
|
|
189
85
|
var formatCryptoAmount = /* @__PURE__ */ __name((value, decimals = 8) => {
|
|
190
|
-
return new
|
|
86
|
+
return new Decimal(value).toDecimalPlaces(decimals).toString();
|
|
191
87
|
}, "formatCryptoAmount");
|
|
192
88
|
var normalizeTxHash = /* @__PURE__ */ __name((hash) => {
|
|
193
89
|
return hash.trim().toLowerCase();
|
|
@@ -203,7 +99,7 @@ var isHexTxHash = /* @__PURE__ */ __name((hash, expectedLength) => {
|
|
|
203
99
|
return true;
|
|
204
100
|
}, "isHexTxHash");
|
|
205
101
|
var isPositiveAmount = /* @__PURE__ */ __name((value) => {
|
|
206
|
-
return new
|
|
102
|
+
return new Decimal(value).greaterThan(DECIMAL_ZERO);
|
|
207
103
|
}, "isPositiveAmount");
|
|
208
104
|
|
|
209
105
|
// src/common/enums/otp.enum.ts
|
|
@@ -226,8 +122,8 @@ var OtpPurpose = /* @__PURE__ */ (function(OtpPurpose2) {
|
|
|
226
122
|
})({});
|
|
227
123
|
|
|
228
124
|
// src/common/dto/pagination-query.dto.ts
|
|
229
|
-
|
|
230
|
-
|
|
125
|
+
import { Type } from "class-transformer";
|
|
126
|
+
import { IsIn, IsInt, IsOptional, IsString, Min } from "class-validator";
|
|
231
127
|
function _ts_decorate(decorators, target, key, desc) {
|
|
232
128
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
233
129
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -259,40 +155,40 @@ var PaginationQueryDto = class {
|
|
|
259
155
|
sortOrder;
|
|
260
156
|
};
|
|
261
157
|
_ts_decorate([
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
158
|
+
Type(() => Number),
|
|
159
|
+
IsInt(),
|
|
160
|
+
Min(1),
|
|
161
|
+
IsOptional(),
|
|
266
162
|
_ts_metadata("design:type", Number)
|
|
267
163
|
], PaginationQueryDto.prototype, "page", void 0);
|
|
268
164
|
_ts_decorate([
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
165
|
+
Type(() => Number),
|
|
166
|
+
IsInt(),
|
|
167
|
+
Min(1),
|
|
168
|
+
IsOptional(),
|
|
273
169
|
_ts_metadata("design:type", Number)
|
|
274
170
|
], PaginationQueryDto.prototype, "limit", void 0);
|
|
275
171
|
_ts_decorate([
|
|
276
|
-
|
|
277
|
-
|
|
172
|
+
IsString(),
|
|
173
|
+
IsOptional(),
|
|
278
174
|
_ts_metadata("design:type", String)
|
|
279
175
|
], PaginationQueryDto.prototype, "search", void 0);
|
|
280
176
|
_ts_decorate([
|
|
281
|
-
|
|
282
|
-
|
|
177
|
+
IsString(),
|
|
178
|
+
IsOptional(),
|
|
283
179
|
_ts_metadata("design:type", String)
|
|
284
180
|
], PaginationQueryDto.prototype, "sortBy", void 0);
|
|
285
181
|
_ts_decorate([
|
|
286
|
-
|
|
182
|
+
IsIn([
|
|
287
183
|
"asc",
|
|
288
184
|
"desc"
|
|
289
185
|
]),
|
|
290
|
-
|
|
186
|
+
IsOptional(),
|
|
291
187
|
_ts_metadata("design:type", String)
|
|
292
188
|
], PaginationQueryDto.prototype, "sortOrder", void 0);
|
|
293
189
|
|
|
294
190
|
// src/common/pipes/file-validation.pipe.ts
|
|
295
|
-
|
|
191
|
+
import { BadRequestException, Injectable } from "@nestjs/common";
|
|
296
192
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
297
193
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
298
194
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -330,7 +226,7 @@ var FileValidationPipe = class {
|
|
|
330
226
|
transform(value) {
|
|
331
227
|
const files = this.normalizeFiles(value);
|
|
332
228
|
if (files.length === 0) {
|
|
333
|
-
throw new
|
|
229
|
+
throw new BadRequestException("No files uploaded");
|
|
334
230
|
}
|
|
335
231
|
this.validateRequiredFields(value);
|
|
336
232
|
const allowedMimeTypes = this.options.allowedMimeTypes ?? DEFAULT_ALLOWED_MIME_TYPES;
|
|
@@ -338,10 +234,10 @@ var FileValidationPipe = class {
|
|
|
338
234
|
for (const file of files) {
|
|
339
235
|
const label = file.fieldname || file.originalname || "file";
|
|
340
236
|
if (file.mimetype && !allowedMimeTypes.includes(file.mimetype)) {
|
|
341
|
-
throw new
|
|
237
|
+
throw new BadRequestException(`${label} must be one of: ${allowedMimeTypes.join(", ")}`);
|
|
342
238
|
}
|
|
343
239
|
if (typeof file.size === "number" && file.size > maxSizeBytes) {
|
|
344
|
-
throw new
|
|
240
|
+
throw new BadRequestException(`${label} size must not exceed ${this.formatFileSize(maxSizeBytes)}`);
|
|
345
241
|
}
|
|
346
242
|
}
|
|
347
243
|
return value;
|
|
@@ -354,7 +250,7 @@ var FileValidationPipe = class {
|
|
|
354
250
|
for (const field of requiredFields) {
|
|
355
251
|
const files = value[field];
|
|
356
252
|
if (!files || files.length === 0) {
|
|
357
|
-
throw new
|
|
253
|
+
throw new BadRequestException(`${field} file is required`);
|
|
358
254
|
}
|
|
359
255
|
}
|
|
360
256
|
}
|
|
@@ -378,7 +274,7 @@ var FileValidationPipe = class {
|
|
|
378
274
|
}
|
|
379
275
|
};
|
|
380
276
|
FileValidationPipe = _ts_decorate2([
|
|
381
|
-
|
|
277
|
+
Injectable(),
|
|
382
278
|
_ts_metadata2("design:type", Function),
|
|
383
279
|
_ts_metadata2("design:paramtypes", [
|
|
384
280
|
typeof FileValidationOptions === "undefined" ? Object : FileValidationOptions
|
|
@@ -386,7 +282,7 @@ FileValidationPipe = _ts_decorate2([
|
|
|
386
282
|
], FileValidationPipe);
|
|
387
283
|
|
|
388
284
|
// src/common/pipes/pagination-query-cleaner.pipe.ts
|
|
389
|
-
|
|
285
|
+
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
390
286
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
391
287
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
392
288
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -415,11 +311,11 @@ var PaginationQueryCleanerPipe = class {
|
|
|
415
311
|
}
|
|
416
312
|
};
|
|
417
313
|
PaginationQueryCleanerPipe = _ts_decorate3([
|
|
418
|
-
(
|
|
314
|
+
Injectable2()
|
|
419
315
|
], PaginationQueryCleanerPipe);
|
|
420
316
|
|
|
421
317
|
// src/common/response/http-exception.filter.ts
|
|
422
|
-
|
|
318
|
+
import { BadRequestException as BadRequestException2, Catch, HttpException, HttpStatus, Logger } from "@nestjs/common";
|
|
423
319
|
|
|
424
320
|
// src/common/response/response.utils.ts
|
|
425
321
|
var AppResponse = class {
|
|
@@ -481,13 +377,13 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
481
377
|
static {
|
|
482
378
|
__name(this, "HttpExceptionFilter");
|
|
483
379
|
}
|
|
484
|
-
logger = new
|
|
380
|
+
logger = new Logger(_HttpExceptionFilter.name);
|
|
485
381
|
catch(exception, host) {
|
|
486
382
|
const ctx = host.switchToHttp();
|
|
487
383
|
const response = ctx.getResponse();
|
|
488
384
|
const request = ctx.getRequest();
|
|
489
|
-
const status = exception instanceof
|
|
490
|
-
const message = exception instanceof
|
|
385
|
+
const status = exception instanceof HttpException ? exception.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;
|
|
386
|
+
const message = exception instanceof HttpException ? exception.message : "An unexpected error occurred";
|
|
491
387
|
const errors = this.getValidationErrors(exception);
|
|
492
388
|
this.logger.error({
|
|
493
389
|
method: request.method,
|
|
@@ -504,7 +400,7 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
504
400
|
response.status(status).send(body);
|
|
505
401
|
}
|
|
506
402
|
getValidationErrors(exception) {
|
|
507
|
-
if (!(exception instanceof
|
|
403
|
+
if (!(exception instanceof BadRequestException2)) {
|
|
508
404
|
return void 0;
|
|
509
405
|
}
|
|
510
406
|
const payload = exception.getResponse();
|
|
@@ -524,11 +420,11 @@ var HttpExceptionFilter = class _HttpExceptionFilter {
|
|
|
524
420
|
}
|
|
525
421
|
};
|
|
526
422
|
HttpExceptionFilter = _ts_decorate4([
|
|
527
|
-
|
|
423
|
+
Catch()
|
|
528
424
|
], HttpExceptionFilter);
|
|
529
425
|
|
|
530
426
|
// src/common/response/http-only-exception.filter.ts
|
|
531
|
-
|
|
427
|
+
import { Catch as Catch2 } from "@nestjs/common";
|
|
532
428
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
533
429
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
534
430
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -556,12 +452,12 @@ var HttpOnlyExceptionFilter = class {
|
|
|
556
452
|
}
|
|
557
453
|
};
|
|
558
454
|
HttpOnlyExceptionFilter = _ts_decorate5([
|
|
559
|
-
(
|
|
455
|
+
Catch2()
|
|
560
456
|
], HttpOnlyExceptionFilter);
|
|
561
457
|
|
|
562
458
|
// src/common/response/response.interceptor.ts
|
|
563
|
-
|
|
564
|
-
|
|
459
|
+
import { Injectable as Injectable3 } from "@nestjs/common";
|
|
460
|
+
import { map } from "rxjs/operators";
|
|
565
461
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
566
462
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
567
463
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -593,7 +489,7 @@ var ResponseInterceptor = class {
|
|
|
593
489
|
return next.handle();
|
|
594
490
|
}
|
|
595
491
|
const request = context.switchToHttp().getRequest();
|
|
596
|
-
return next.handle().pipe(
|
|
492
|
+
return next.handle().pipe(map((data) => {
|
|
597
493
|
if (isApiResponse(data)) {
|
|
598
494
|
return data;
|
|
599
495
|
}
|
|
@@ -613,11 +509,11 @@ var ResponseInterceptor = class {
|
|
|
613
509
|
}
|
|
614
510
|
};
|
|
615
511
|
ResponseInterceptor = _ts_decorate6([
|
|
616
|
-
(
|
|
512
|
+
Injectable3()
|
|
617
513
|
], ResponseInterceptor);
|
|
618
514
|
|
|
619
515
|
// src/common/utils/country.utils.ts
|
|
620
|
-
|
|
516
|
+
import * as CountryCodeList from "country-codes-list";
|
|
621
517
|
var countryDialCodes = Object.keys(CountryCodeList.customList("countryCallingCode")).map((code) => `+${code}`);
|
|
622
518
|
|
|
623
519
|
// src/common/utils/date.utils.ts
|
|
@@ -659,15 +555,15 @@ var isValidAge = /* @__PURE__ */ __name((dateOfBirth, minAge = 18) => {
|
|
|
659
555
|
}, "isValidAge");
|
|
660
556
|
|
|
661
557
|
// src/common/utils/decimal.utils.ts
|
|
662
|
-
|
|
558
|
+
import Decimal2 from "decimal.js";
|
|
663
559
|
var DEFAULT_DECIMAL_PLACES = 4;
|
|
664
|
-
|
|
560
|
+
Decimal2.set({
|
|
665
561
|
precision: 20,
|
|
666
|
-
rounding:
|
|
562
|
+
rounding: Decimal2.ROUND_HALF_UP
|
|
667
563
|
});
|
|
668
564
|
var toDecimal = /* @__PURE__ */ __name((value) => {
|
|
669
565
|
try {
|
|
670
|
-
return new
|
|
566
|
+
return new Decimal2(value);
|
|
671
567
|
} catch {
|
|
672
568
|
throw new Error(`Invalid decimal value: ${value}`);
|
|
673
569
|
}
|
|
@@ -878,13 +774,13 @@ var isValidTransactionReference = /* @__PURE__ */ __name((reference) => {
|
|
|
878
774
|
}, "isValidTransactionReference");
|
|
879
775
|
|
|
880
776
|
// src/common/config/nats.config.ts
|
|
881
|
-
|
|
777
|
+
import { Transport } from "@nestjs/microservices";
|
|
882
778
|
var getNatsServers = /* @__PURE__ */ __name((configService) => {
|
|
883
|
-
const rawServers = configService.get("
|
|
779
|
+
const rawServers = configService.get("NATS_URL") ?? "nats://localhost:4222";
|
|
884
780
|
return rawServers.split(",").map((server) => server.trim()).filter(Boolean);
|
|
885
781
|
}, "getNatsServers");
|
|
886
782
|
var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
|
|
887
|
-
transport:
|
|
783
|
+
transport: Transport.NATS,
|
|
888
784
|
options: {
|
|
889
785
|
servers: getNatsServers(configService)
|
|
890
786
|
}
|
|
@@ -892,7 +788,7 @@ var getNatsMicroserviceConfig = /* @__PURE__ */ __name((configService) => ({
|
|
|
892
788
|
var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
893
789
|
const queue = queueName && configService.get(`NATS_${queueName.toUpperCase()}_QUEUE`);
|
|
894
790
|
return {
|
|
895
|
-
transport:
|
|
791
|
+
transport: Transport.NATS,
|
|
896
792
|
options: {
|
|
897
793
|
servers: getNatsServers(configService),
|
|
898
794
|
...queue ? {
|
|
@@ -901,8 +797,7 @@ var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
|
901
797
|
}
|
|
902
798
|
};
|
|
903
799
|
}, "getNatsConfig");
|
|
904
|
-
|
|
905
|
-
0 && (module.exports = {
|
|
800
|
+
export {
|
|
906
801
|
AppResponse,
|
|
907
802
|
BANKING_QUEUE,
|
|
908
803
|
CARD_QUEUE,
|
|
@@ -975,5 +870,5 @@ var getNatsConfig = /* @__PURE__ */ __name((configService, queueName) => {
|
|
|
975
870
|
toRoundedNumber,
|
|
976
871
|
toTitleCase,
|
|
977
872
|
truncateText
|
|
978
|
-
}
|
|
873
|
+
};
|
|
979
874
|
//# sourceMappingURL=index.js.map
|