@6thbridge/utils 0.1.16
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/lib/actions/charge.action.d.ts +9 -0
- package/lib/actions/charge.action.js +74 -0
- package/lib/actions/charge.action.js.map +1 -0
- package/lib/actions/currency.action.d.ts +15 -0
- package/lib/actions/currency.action.js +57 -0
- package/lib/actions/currency.action.js.map +1 -0
- package/lib/actions/index.d.ts +9 -0
- package/lib/actions/index.js +33 -0
- package/lib/actions/index.js.map +1 -0
- package/lib/actions/phone-number.action.d.ts +23 -0
- package/lib/actions/phone-number.action.js +77 -0
- package/lib/actions/phone-number.action.js.map +1 -0
- package/lib/brokers/index.d.ts +6 -0
- package/lib/brokers/index.js +8 -0
- package/lib/brokers/index.js.map +1 -0
- package/lib/brokers/kafka.d.ts +84 -0
- package/lib/brokers/kafka.js +265 -0
- package/lib/brokers/kafka.js.map +1 -0
- package/lib/brokers/kafka.test.d.ts +1 -0
- package/lib/brokers/kafka.test.js +118 -0
- package/lib/brokers/kafka.test.js.map +1 -0
- package/lib/brokers/rabbitmq.d.ts +108 -0
- package/lib/brokers/rabbitmq.js +290 -0
- package/lib/brokers/rabbitmq.js.map +1 -0
- package/lib/cache/in-memory.d.ts +0 -0
- package/lib/cache/in-memory.js +2 -0
- package/lib/cache/in-memory.js.map +1 -0
- package/lib/cache/redis.d.ts +18 -0
- package/lib/cache/redis.js +58 -0
- package/lib/cache/redis.js.map +1 -0
- package/lib/database/MongoDBRepository.d.ts +23 -0
- package/lib/database/MongoDBRepository.js +90 -0
- package/lib/database/MongoDBRepository.js.map +1 -0
- package/lib/database/MongoDBTypeRepository.d.ts +26 -0
- package/lib/database/MongoDBTypeRepository.js +90 -0
- package/lib/database/MongoDBTypeRepository.js.map +1 -0
- package/lib/database/index.d.ts +4 -0
- package/lib/database/index.js +36 -0
- package/lib/database/index.js.map +1 -0
- package/lib/database/query.d.ts +16 -0
- package/lib/database/query.js +82 -0
- package/lib/database/query.js.map +1 -0
- package/lib/exceptions/custom.exception.d.ts +14 -0
- package/lib/exceptions/custom.exception.js +16 -0
- package/lib/exceptions/custom.exception.js.map +1 -0
- package/lib/helpers/errors.d.ts +2 -0
- package/lib/helpers/errors.js +46 -0
- package/lib/helpers/errors.js.map +1 -0
- package/lib/helpers/index.d.ts +51 -0
- package/lib/helpers/index.js +198 -0
- package/lib/helpers/index.js.map +1 -0
- package/lib/helpers/utils.d.ts +9 -0
- package/lib/helpers/utils.js +18 -0
- package/lib/helpers/utils.js.map +1 -0
- package/lib/http/axios.d.ts +0 -0
- package/lib/http/axios.js +2 -0
- package/lib/http/axios.js.map +1 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +104 -0
- package/lib/index.js.map +1 -0
- package/lib/logger/index.d.ts +20 -0
- package/lib/logger/index.js +12 -0
- package/lib/logger/index.js.map +1 -0
- package/lib/logger/logger-test.d.ts +1 -0
- package/lib/logger/logger-test.js +40 -0
- package/lib/logger/logger-test.js.map +1 -0
- package/lib/logger/logger.d.ts +31 -0
- package/lib/logger/logger.js +106 -0
- package/lib/logger/logger.js.map +1 -0
- package/lib/logger/null-logger.d.ts +14 -0
- package/lib/logger/null-logger.js +29 -0
- package/lib/logger/null-logger.js.map +1 -0
- package/lib/logger/test.d.ts +1 -0
- package/lib/logger/test.js +45 -0
- package/lib/logger/test.js.map +1 -0
- package/lib/middlewares/common.d.ts +22 -0
- package/lib/middlewares/common.js +141 -0
- package/lib/middlewares/common.js.map +1 -0
- package/lib/middlewares/express.d.ts +4 -0
- package/lib/middlewares/express.js +99 -0
- package/lib/middlewares/express.js.map +1 -0
- package/lib/middlewares/fastify.d.ts +4 -0
- package/lib/middlewares/fastify.js +73 -0
- package/lib/middlewares/fastify.js.map +1 -0
- package/lib/middlewares/index.d.ts +4 -0
- package/lib/middlewares/index.js +34 -0
- package/lib/middlewares/index.js.map +1 -0
- package/lib/monitoring/index.d.ts +12 -0
- package/lib/monitoring/index.js +75 -0
- package/lib/monitoring/index.js.map +1 -0
- package/lib/responses/express.d.ts +26 -0
- package/lib/responses/express.js +98 -0
- package/lib/responses/express.js.map +1 -0
- package/lib/responses/fastify.d.ts +4 -0
- package/lib/responses/fastify.js +25 -0
- package/lib/responses/fastify.js.map +1 -0
- package/lib/responses/index.d.ts +3 -0
- package/lib/responses/index.js +31 -0
- package/lib/responses/index.js.map +1 -0
- package/lib/secrets/aws-secret.d.ts +4 -0
- package/lib/secrets/aws-secret.js +55 -0
- package/lib/secrets/aws-secret.js.map +1 -0
- package/lib/secrets/aws.d.ts +0 -0
- package/lib/secrets/aws.js +2 -0
- package/lib/secrets/aws.js.map +1 -0
- package/lib/secrets/index.d.ts +8 -0
- package/lib/secrets/index.js +18 -0
- package/lib/secrets/index.js.map +1 -0
- package/lib/test/actions/charge.action.test.d.ts +1 -0
- package/lib/test/actions/charge.action.test.js +86 -0
- package/lib/test/actions/charge.action.test.js.map +1 -0
- package/lib/test/database/test.spec.d.ts +1 -0
- package/lib/test/database/test.spec.js +74 -0
- package/lib/test/database/test.spec.js.map +1 -0
- package/lib/test/helpers/PhoneNumber.spec.d.ts +1 -0
- package/lib/test/helpers/PhoneNumber.spec.js +82 -0
- package/lib/test/helpers/PhoneNumber.spec.js.map +1 -0
- package/lib/test/logger/test.spec.d.ts +1 -0
- package/lib/test/logger/test.spec.js +37 -0
- package/lib/test/logger/test.spec.js.map +1 -0
- package/lib/test/types/context.entity.test.d.ts +1 -0
- package/lib/test/types/context.entity.test.js +29 -0
- package/lib/test/types/context.entity.test.js.map +1 -0
- package/lib/translations/index.d.ts +7 -0
- package/lib/translations/index.js +52 -0
- package/lib/translations/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/broker.entity.d.ts +15 -0
- package/lib/types/broker.entity.js +13 -0
- package/lib/types/broker.entity.js.map +1 -0
- package/lib/types/client.entity.d.ts +42 -0
- package/lib/types/client.entity.js +16 -0
- package/lib/types/client.entity.js.map +1 -0
- package/lib/types/context.entity.d.ts +43 -0
- package/lib/types/context.entity.js +105 -0
- package/lib/types/context.entity.js.map +1 -0
- package/lib/types/index.d.ts +82 -0
- package/lib/types/index.js +38 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/user.entity.d.ts +28 -0
- package/lib/types/user.entity.js +18 -0
- package/lib/types/user.entity.js.map +1 -0
- package/package.json +52 -0
- package/readme.md +66 -0
|
@@ -0,0 +1,36 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.mongoosePaginate = exports.query = exports.MongoDBRepository = void 0;
|
|
30
|
+
const MongoDBRepository_1 = require("./MongoDBRepository");
|
|
31
|
+
Object.defineProperty(exports, "MongoDBRepository", { enumerable: true, get: function () { return MongoDBRepository_1.MongoDBRepository; } });
|
|
32
|
+
const query = __importStar(require("./query"));
|
|
33
|
+
exports.query = query;
|
|
34
|
+
const mongoose_paginate_v2_1 = __importDefault(require("mongoose-paginate-v2"));
|
|
35
|
+
exports.mongoosePaginate = mongoose_paginate_v2_1.default;
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/database/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAsD;AAIlD,kGAJI,qCAAiB,OAIJ;AAHrB,+CAAiC;AAI7B,sBAAK;AAHT,gFAAoD;AAIhD,2BAJG,8BAAgB,CAIH"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description resolveRequestQueryToMongoDBQuery
|
|
3
|
+
* @param {object} requestQuery
|
|
4
|
+
* @returns {{filter: {}, limit: number, page: number, sort: {_id: number}}}
|
|
5
|
+
*/
|
|
6
|
+
export declare class ObjectToMongoDBQueryOption {
|
|
7
|
+
dateField?: string;
|
|
8
|
+
searchFields?: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class ObjectToMongoDBQueryResult {
|
|
11
|
+
page?: number;
|
|
12
|
+
limit?: number;
|
|
13
|
+
filter: any;
|
|
14
|
+
sort: any;
|
|
15
|
+
}
|
|
16
|
+
export declare function resolveObjectToMongoDBQuery(requestQuery: any, options?: ObjectToMongoDBQueryOption): ObjectToMongoDBQueryResult;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveObjectToMongoDBQuery = exports.ObjectToMongoDBQueryResult = exports.ObjectToMongoDBQueryOption = void 0;
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
/**
|
|
6
|
+
* @description resolveRequestQueryToMongoDBQuery
|
|
7
|
+
* @param {object} requestQuery
|
|
8
|
+
* @returns {{filter: {}, limit: number, page: number, sort: {_id: number}}}
|
|
9
|
+
*/
|
|
10
|
+
class ObjectToMongoDBQueryOption {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.dateField = "createdAt";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.ObjectToMongoDBQueryOption = ObjectToMongoDBQueryOption;
|
|
16
|
+
class ObjectToMongoDBQueryResult {
|
|
17
|
+
constructor() {
|
|
18
|
+
this.page = 1;
|
|
19
|
+
this.limit = 50;
|
|
20
|
+
this.filter = {};
|
|
21
|
+
this.sort = { _id: -1 };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ObjectToMongoDBQueryResult = ObjectToMongoDBQueryResult;
|
|
25
|
+
function resolveObjectToMongoDBQuery(requestQuery, options) {
|
|
26
|
+
var _a;
|
|
27
|
+
if (!options) {
|
|
28
|
+
options = {
|
|
29
|
+
dateField: "createdAt"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const response = {
|
|
33
|
+
page: 1,
|
|
34
|
+
limit: 50,
|
|
35
|
+
filter: {},
|
|
36
|
+
sort: { _id: -1 }
|
|
37
|
+
};
|
|
38
|
+
for (const key of Object.keys(requestQuery)) {
|
|
39
|
+
if (key === "page") {
|
|
40
|
+
response.page = parseInt(requestQuery[key]);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (key === "limit") {
|
|
44
|
+
response.limit = parseInt(requestQuery[key]);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (key === "sort") {
|
|
48
|
+
const [sortKey, sortValue] = requestQuery[key].split(",");
|
|
49
|
+
response.sort = { [sortKey]: sortValue || -1 };
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (key === "dateFrom") {
|
|
53
|
+
response.filter[options.dateField || "createdAt"] = Object.assign(Object.assign({}, response.filter[options.dateField || "createdAt"]), { $gte: (0, helpers_1.dayjs)(requestQuery[key] || new Date(), "DD-MM-YYYY")
|
|
54
|
+
.endOf("day") });
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (key === "dateTo") {
|
|
58
|
+
response.filter[options.dateField || "createdAt"] = Object.assign(Object.assign({}, response.filter[options.dateField || "createdAt"]), { $lte: (0, helpers_1.dayjs)(requestQuery[key] || new Date(), "DD-MM-YYYY")
|
|
59
|
+
.endOf("day") });
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
//query
|
|
63
|
+
if (key === "q") {
|
|
64
|
+
if (!((_a = options.searchFields) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
65
|
+
response.filter.$text = {
|
|
66
|
+
$search: new RegExp(requestQuery[key], "gi"),
|
|
67
|
+
$caseSensitive: false
|
|
68
|
+
};
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
response.filter.$or = [...(response.filter.$or || [])];
|
|
72
|
+
options.searchFields.forEach(field => {
|
|
73
|
+
response.filter.$or.push({ [field]: new RegExp(requestQuery[key], "gi") });
|
|
74
|
+
});
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
response.filter[key] = requestQuery[key];
|
|
78
|
+
}
|
|
79
|
+
return response;
|
|
80
|
+
}
|
|
81
|
+
exports.resolveObjectToMongoDBQuery = resolveObjectToMongoDBQuery;
|
|
82
|
+
//# sourceMappingURL=query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.js","sourceRoot":"","sources":["../../src/database/query.ts"],"names":[],"mappings":";;;AAAA,wCAAiC;AAGjC;;;;GAIG;AAEH,MAAa,0BAA0B;IAAvC;QACI,cAAS,GAAY,WAAW,CAAA;IAEpC,CAAC;CAAA;AAHD,gEAGC;A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AC,GAAG,CAAC,EAAE,IAAI,CAAC,EAAC,CAAC,CAAA;YAC5E,CAAC,CAAC,CAAA;YACF,SAAS;QACb,CAAC;QAED,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAtED,kEAsEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class CustomExceptionParams {
|
|
2
|
+
message: string;
|
|
3
|
+
errorCode?: string;
|
|
4
|
+
statusCode?: number;
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
}
|
|
7
|
+
export declare class CustomException extends Error {
|
|
8
|
+
message: string;
|
|
9
|
+
statusCode: string | number;
|
|
10
|
+
errorCode: string;
|
|
11
|
+
params: CustomExceptionParams;
|
|
12
|
+
constructor(params: CustomExceptionParams);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomException = void 0;
|
|
4
|
+
class CustomExceptionParams {
|
|
5
|
+
}
|
|
6
|
+
class CustomException extends Error {
|
|
7
|
+
constructor(params) {
|
|
8
|
+
super(params.message);
|
|
9
|
+
this.message = params.message;
|
|
10
|
+
this.errorCode = params.errorCode || "error";
|
|
11
|
+
this.statusCode = params.statusCode || 500;
|
|
12
|
+
this.params = params;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.CustomException = CustomException;
|
|
16
|
+
//# sourceMappingURL=custom.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.exception.js","sourceRoot":"","sources":["../../src/exceptions/custom.exception.ts"],"names":[],"mappings":";;;AACA,MAAM,qBAAqB;CAM1B;AAED,MAAa,eAAgB,SAAQ,KAAK;IAMxC,YAAa,MAA6B;QACxC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAEtB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,OAAO,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAdD,0CAcC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAxiosError = void 0;
|
|
4
|
+
const logger_1 = require("../logger/logger");
|
|
5
|
+
function resolveAxiosError(error) {
|
|
6
|
+
let formattedError;
|
|
7
|
+
try {
|
|
8
|
+
if (error === null || error === void 0 ? void 0 : error.response) {
|
|
9
|
+
formattedError = {
|
|
10
|
+
status: error.response.status,
|
|
11
|
+
statusText: error.response.statusText,
|
|
12
|
+
message: error.response.data.error,
|
|
13
|
+
url: error.response.config.url,
|
|
14
|
+
params: error.response.config.params,
|
|
15
|
+
data: error.response.config.data,
|
|
16
|
+
headers: error.response.headers,
|
|
17
|
+
raw: error.response.data,
|
|
18
|
+
stackTrace: new Error().stack
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
formattedError = {
|
|
23
|
+
status: 500,
|
|
24
|
+
statusText: error.message || "Unknown Error",
|
|
25
|
+
message: error.message || "Oops, An Error Occurred",
|
|
26
|
+
stack: error.stack,
|
|
27
|
+
stackTrace: new Error().stack
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (ex) {
|
|
32
|
+
formattedError = {
|
|
33
|
+
status: 500,
|
|
34
|
+
statusText: "Unknown Error",
|
|
35
|
+
message: "Oops, An Error Occurred",
|
|
36
|
+
error: ex.message,
|
|
37
|
+
stack: ex.stack
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
logger_1.logger.error(formattedError.message, formattedError);
|
|
42
|
+
}
|
|
43
|
+
return formattedError;
|
|
44
|
+
}
|
|
45
|
+
exports.resolveAxiosError = resolveAxiosError;
|
|
46
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/helpers/errors.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAGxC,SAAgB,iBAAiB,CAAC,KAA+B;IAC7D,IAAI,cAAmB,CAAC;IACxB,IAAI,CAAC;QACD,IAAI,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,EAAE,CAAC;YAClB,cAAc,GAAG;gBACb,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM;gBAC7B,UAAU,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU;gBACrC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK;gBAClC,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG;gBAC9B,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM;gBACpC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI;gBAChC,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,OAAO;gBAC/B,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,IAAI;gBACxB,UAAU,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK;aAChC,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,cAAc,GAAG;gBACb,MAAM,EAAE,GAAG;gBACX,UAAU,EAAE,KAAK,CAAC,OAAO,IAAI,eAAe;gBAC5C,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,yBAAyB;gBACnD,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,UAAU,EAAE,IAAI,KAAK,EAAE,CAAC,KAAK;aAChC,CAAC;QACN,CAAC;IAEL,CAAC;IAAC,OAAO,EAAO,EAAE,CAAC;QACf,cAAc,GAAG;YACb,MAAM,EAAE,GAAG;YACX,UAAU,EAAE,eAAe;YAC3B,OAAO,EAAE,yBAAyB;YAClC,KAAK,EAAE,EAAE,CAAC,OAAO;YACjB,KAAK,EAAE,EAAE,CAAC,KAAK;SAClB,CAAC;IACN,CAAC;YAAS,CAAC;QACP,eAAM,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,cAAc,CAAC;AAC1B,CAAC;AArCD,8CAqCC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as Joi from "joi";
|
|
2
|
+
import randomstring from "randomstring";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import { isEmpty } from "lodash";
|
|
5
|
+
import { CountryCode } from "libphonenumber-js";
|
|
6
|
+
import * as errors from "./errors";
|
|
7
|
+
import { resolveObjectToMongoDBQuery } from "../database/query";
|
|
8
|
+
import { SaveActivityLogDTO } from "../types";
|
|
9
|
+
export declare const ACTIVITY_LOG_QUEUE = "activity.log";
|
|
10
|
+
export declare function removeFieldsWithEmptyValue(value: any): any;
|
|
11
|
+
export declare function validate(schema: any, payload: any): any;
|
|
12
|
+
export declare function validateStrict(schema: any, payload: any, options?: any): {
|
|
13
|
+
error: any;
|
|
14
|
+
data?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
data: any;
|
|
17
|
+
error?: undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* This method formats a Nigerian Phone number
|
|
21
|
+
* @param {string|Array} phoneNumber
|
|
22
|
+
* @param {string|undefined} countryCode
|
|
23
|
+
* @return "+234xxxxxxxxx"|undefined|array
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatPhoneNumber(phoneNumber: string, countryCode?: string): string | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated User phone number function in actions
|
|
28
|
+
* @param phoneNumber
|
|
29
|
+
* @param countryCode
|
|
30
|
+
*/
|
|
31
|
+
export declare function isPhoneNumberValid(phoneNumber: string, countryCode: CountryCode | string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated User phone number function in actions
|
|
34
|
+
* @param phoneNumber
|
|
35
|
+
* @param countryCode
|
|
36
|
+
*/
|
|
37
|
+
export declare function isPhoneNumberPossible(phoneNumber: string, countryCode: CountryCode | string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* This method formats a Nigerian Phone number
|
|
40
|
+
* @param {Array} phoneNumbers
|
|
41
|
+
* @param {string|undefined} countryCode
|
|
42
|
+
* @return "+234xxxxxxxxx"|undefined|array
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatPhoneNumberArray(phoneNumbers: (string | undefined)[], countryCode?: string): (string | undefined)[];
|
|
45
|
+
export declare function format(phoneNumber: string | undefined, countryCode: CountryCode): string | undefined;
|
|
46
|
+
export declare const resolveRequestQueryToMongoDBQuery: typeof resolveObjectToMongoDBQuery;
|
|
47
|
+
declare function saveActivityLog(activityLog: SaveActivityLogDTO, options?: any): Promise<void>;
|
|
48
|
+
declare const generateReference: (env: string) => string;
|
|
49
|
+
declare function generateUUID(options?: any): `${string}-${string}-${string}-${string}-${string}`;
|
|
50
|
+
declare function sleep(durationInMs?: number): Promise<unknown>;
|
|
51
|
+
export { Joi, isEmpty, dayjs, errors, saveActivityLog, randomstring, generateUUID, generateReference, sleep };
|
|
@@ -0,0 +1,198 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.sleep = exports.generateReference = exports.generateUUID = exports.randomstring = exports.saveActivityLog = exports.errors = exports.dayjs = exports.isEmpty = exports.Joi = exports.resolveRequestQueryToMongoDBQuery = exports.format = exports.formatPhoneNumberArray = exports.isPhoneNumberPossible = exports.isPhoneNumberValid = exports.formatPhoneNumber = exports.validateStrict = exports.validate = exports.removeFieldsWithEmptyValue = exports.ACTIVITY_LOG_QUEUE = void 0;
|
|
39
|
+
const crypto_1 = require("crypto");
|
|
40
|
+
const Joi = __importStar(require("joi"));
|
|
41
|
+
exports.Joi = Joi;
|
|
42
|
+
const randomstring_1 = __importDefault(require("randomstring"));
|
|
43
|
+
exports.randomstring = randomstring_1.default;
|
|
44
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
45
|
+
exports.dayjs = dayjs_1.default;
|
|
46
|
+
const lodash_1 = require("lodash");
|
|
47
|
+
Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return lodash_1.isEmpty; } });
|
|
48
|
+
const localizedFormat_1 = __importDefault(require("dayjs/plugin/localizedFormat"));
|
|
49
|
+
const timezone_1 = __importDefault(require("dayjs/plugin/timezone"));
|
|
50
|
+
const libphonenumber_js_1 = require("libphonenumber-js");
|
|
51
|
+
const errors = __importStar(require("./errors"));
|
|
52
|
+
exports.errors = errors;
|
|
53
|
+
const query_1 = require("../database/query");
|
|
54
|
+
const axios_1 = __importDefault(require("axios"));
|
|
55
|
+
const logger_1 = require("../logger/logger");
|
|
56
|
+
dayjs_1.default.extend(localizedFormat_1.default);
|
|
57
|
+
dayjs_1.default.extend(timezone_1.default);
|
|
58
|
+
dayjs_1.default.tz.setDefault(process.env.TZ || "Africa/Lagos");
|
|
59
|
+
/**
|
|
60
|
+
* @param {object} value
|
|
61
|
+
* @returns {object}
|
|
62
|
+
*/
|
|
63
|
+
const dataToBeRemovedArray = ["", null, undefined];
|
|
64
|
+
exports.ACTIVITY_LOG_QUEUE = "activity.log";
|
|
65
|
+
function removeFieldsWithEmptyValue(value) {
|
|
66
|
+
const objectTobeWorkingOn = Object.assign({}, value);
|
|
67
|
+
if (typeof value != "object")
|
|
68
|
+
return value;
|
|
69
|
+
for (const key in objectTobeWorkingOn) {
|
|
70
|
+
if (dataToBeRemovedArray.includes(objectTobeWorkingOn[key])) {
|
|
71
|
+
delete objectTobeWorkingOn[key];
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(objectTobeWorkingOn[key])) {
|
|
75
|
+
objectTobeWorkingOn[key] = objectTobeWorkingOn[key].map(removeFieldsWithEmptyValue);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (typeof objectTobeWorkingOn[key] === "object") {
|
|
79
|
+
objectTobeWorkingOn[key] = removeFieldsWithEmptyValue(objectTobeWorkingOn[key]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return objectTobeWorkingOn;
|
|
83
|
+
}
|
|
84
|
+
exports.removeFieldsWithEmptyValue = removeFieldsWithEmptyValue;
|
|
85
|
+
function validate(schema, payload) {
|
|
86
|
+
schema = Joi.object(schema);
|
|
87
|
+
const { error } = schema.validate(payload, {
|
|
88
|
+
allowUnknown: true,
|
|
89
|
+
});
|
|
90
|
+
if (error)
|
|
91
|
+
return error.details[0].message.replace(/['"]/g, "");
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
exports.validate = validate;
|
|
95
|
+
function validateStrict(schema, payload, options = {}) {
|
|
96
|
+
schema = Joi.object(schema);
|
|
97
|
+
const { error, value } = schema.validate(payload, Object.assign({ allowUnknown: true }, options));
|
|
98
|
+
if (error)
|
|
99
|
+
return { error: error.details[0].message.replace(/['"]/g, "") };
|
|
100
|
+
return { data: value };
|
|
101
|
+
}
|
|
102
|
+
exports.validateStrict = validateStrict;
|
|
103
|
+
/**
|
|
104
|
+
* This method formats a Nigerian Phone number
|
|
105
|
+
* @param {string|Array} phoneNumber
|
|
106
|
+
* @param {string|undefined} countryCode
|
|
107
|
+
* @return "+234xxxxxxxxx"|undefined|array
|
|
108
|
+
*/
|
|
109
|
+
function formatPhoneNumber(phoneNumber, countryCode = "NG") {
|
|
110
|
+
if ((0, lodash_1.isEmpty)(phoneNumber))
|
|
111
|
+
return phoneNumber;
|
|
112
|
+
return format(phoneNumber, countryCode);
|
|
113
|
+
}
|
|
114
|
+
exports.formatPhoneNumber = formatPhoneNumber;
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated User phone number function in actions
|
|
117
|
+
* @param phoneNumber
|
|
118
|
+
* @param countryCode
|
|
119
|
+
*/
|
|
120
|
+
function isPhoneNumberValid(phoneNumber, countryCode) {
|
|
121
|
+
return (0, libphonenumber_js_1.isValidNumberForRegion)(phoneNumber, countryCode);
|
|
122
|
+
}
|
|
123
|
+
exports.isPhoneNumberValid = isPhoneNumberValid;
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated User phone number function in actions
|
|
126
|
+
* @param phoneNumber
|
|
127
|
+
* @param countryCode
|
|
128
|
+
*/
|
|
129
|
+
function isPhoneNumberPossible(phoneNumber, countryCode) {
|
|
130
|
+
return (0, libphonenumber_js_1.isPossiblePhoneNumber)(phoneNumber, countryCode);
|
|
131
|
+
}
|
|
132
|
+
exports.isPhoneNumberPossible = isPhoneNumberPossible;
|
|
133
|
+
/**
|
|
134
|
+
* This method formats a Nigerian Phone number
|
|
135
|
+
* @param {Array} phoneNumbers
|
|
136
|
+
* @param {string|undefined} countryCode
|
|
137
|
+
* @return "+234xxxxxxxxx"|undefined|array
|
|
138
|
+
*/
|
|
139
|
+
function formatPhoneNumberArray(phoneNumbers, countryCode = "NG") {
|
|
140
|
+
if ((0, lodash_1.isEmpty)(phoneNumbers))
|
|
141
|
+
return phoneNumbers;
|
|
142
|
+
return phoneNumbers.filter(Boolean).map(phone => {
|
|
143
|
+
return format(phone, countryCode);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
exports.formatPhoneNumberArray = formatPhoneNumberArray;
|
|
147
|
+
function format(phoneNumber, countryCode) {
|
|
148
|
+
if (!phoneNumber)
|
|
149
|
+
return undefined;
|
|
150
|
+
phoneNumber = phoneNumber.toString().replace(/\D/g, "");
|
|
151
|
+
const response = (0, libphonenumber_js_1.parsePhoneNumberFromString)(phoneNumber, countryCode);
|
|
152
|
+
if (!response || (0, lodash_1.isEmpty)(response))
|
|
153
|
+
return undefined;
|
|
154
|
+
return `${response.countryCallingCode}${response.nationalNumber}`;
|
|
155
|
+
}
|
|
156
|
+
exports.format = format;
|
|
157
|
+
exports.resolveRequestQueryToMongoDBQuery = query_1.resolveObjectToMongoDBQuery;
|
|
158
|
+
function saveActivityLog(activityLog_1) {
|
|
159
|
+
return __awaiter(this, arguments, void 0, function* (activityLog, options = {}) {
|
|
160
|
+
var _a;
|
|
161
|
+
if (!options.broker && !process.env.USER_SERVICE_URL)
|
|
162
|
+
throw Error("ActivityLog: cant post activity log, Broker and USER_SERVICE_URL is missing");
|
|
163
|
+
if (options.broker) {
|
|
164
|
+
(_a = options.broker) === null || _a === void 0 ? void 0 : _a.sendToQueue(exports.ACTIVITY_LOG_QUEUE, {
|
|
165
|
+
event: exports.ACTIVITY_LOG_QUEUE,
|
|
166
|
+
data: activityLog
|
|
167
|
+
});
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
axios_1.default.post(`${process.env.USER_SERVICE_URL}/v1/activity-logs`, activityLog, {
|
|
171
|
+
headers: {
|
|
172
|
+
source: "internal"
|
|
173
|
+
}
|
|
174
|
+
}).catch(logger_1.logger.exception);
|
|
175
|
+
return;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.saveActivityLog = saveActivityLog;
|
|
179
|
+
const generateReference = (env) => {
|
|
180
|
+
const envCode = env == "production" ? "L" : "D";
|
|
181
|
+
// return clientId.toUpperCase() + envCode + dayjs().format("YYYYMMDDHHmmss").toString() +
|
|
182
|
+
return envCode + (0, dayjs_1.default)().format("YYYYMMDDHHmmss").toString() + randomstring_1.default.generate({
|
|
183
|
+
length: 5,
|
|
184
|
+
charset: 'alphabetic'
|
|
185
|
+
}).toUpperCase();
|
|
186
|
+
};
|
|
187
|
+
exports.generateReference = generateReference;
|
|
188
|
+
function generateUUID(options) {
|
|
189
|
+
return (0, crypto_1.randomUUID)(options);
|
|
190
|
+
}
|
|
191
|
+
exports.generateUUID = generateUUID;
|
|
192
|
+
function sleep() {
|
|
193
|
+
return __awaiter(this, arguments, void 0, function* (durationInMs = 1000) {
|
|
194
|
+
return new Promise(resolve => setTimeout(resolve, durationInMs));
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
exports.sleep = sleep;
|
|
198
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,mCAAkC;AAClC,yCAA2B;AAkLvB,kBAAG;AAjLP,gEAAwC;AAsLpC,uBAtLG,sBAAY,CAsLH;AArLhB,kDAA0B;AAkLtB,gBAlLG,eAAK,CAkLH;AAjLT,mCAA+B;AAgL3B,wFAhLI,gBAAO,OAgLJ;AA/KX,mFAA2D;AAC3D,qEAA6C;AAC7C,yDAAyH;AAEzH,iDAAmC;AA6K/B,wBAAM;AA5KV,6CAA8D;AAC9D,kDAA0B;AAC1B,6CAAwC;AAIxC,eAAK,CAAC,MAAM,CAAC,yBAAe,CAAC,CAAC;AAC9B,eAAK,CAAC,MAAM,CAAC,kBAAQ,CAAC,CAAC;AACvB,eAAK,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,cAAc,CAAC,CAAC;AAEtD;;;GAGG;AACH,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AAEtC,QAAA,kBAAkB,GAAG,cAAc,CAAC;AAEjD,SAAgB,0BAA0B,CAAC,KAAU;IACjD,MAAM,mBAAmB,qBAAO,KAAK,CAAC,CAAC;IAEvC,IAAI,OAAO,KAAK,IAAI,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,mBAAmB,EAAE,C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,EAAE,GAAG,sBAAY,CAAC,QAAQ,CAAC;QACjF,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,YAAY;KACxB,CAAC,CAAC,WAAW,EAAE,CAAA;AACpB,CAAC,CAAC;AAkBE,8CAAiB;AAhBrB,SAAS,YAAY,CAAC,OAAa;IAC/B,OAAO,IAAA,mBAAU,EAAC,OAAO,CAAC,CAAA;AAC9B,CAAC;AAaG,oCAAY;AAXhB,SAAe,KAAK;yDAAC,eAAuB,IAAI;QAC5C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IACrE,CAAC;CAAA;AAWG,sBAAK"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RequestUserEntity, UserEntity } from "../types";
|
|
2
|
+
declare function getUserFirstName(user: RequestUserEntity | UserEntity): string | undefined;
|
|
3
|
+
export declare class FormatUserOrGetUserByIdPayload {
|
|
4
|
+
userServiceURL?: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
user?: UserEntity | RequestUserEntity;
|
|
7
|
+
}
|
|
8
|
+
declare function formatUserOrGetUserById(payload: FormatUserOrGetUserByIdPayload): void;
|
|
9
|
+
export { getUserFirstName, formatUserOrGetUserById };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatUserOrGetUserById = exports.getUserFirstName = exports.FormatUserOrGetUserByIdPayload = void 0;
|
|
4
|
+
function getUserFirstName(user) {
|
|
5
|
+
var _a;
|
|
6
|
+
return user.firstName || ((_a = user.name) === null || _a === void 0 ? void 0 : _a.split(" ")[0]) || user.name;
|
|
7
|
+
}
|
|
8
|
+
exports.getUserFirstName = getUserFirstName;
|
|
9
|
+
class FormatUserOrGetUserByIdPayload {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.userServiceURL = "http://user-service";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.FormatUserOrGetUserByIdPayload = FormatUserOrGetUserByIdPayload;
|
|
15
|
+
function formatUserOrGetUserById(payload) {
|
|
16
|
+
}
|
|
17
|
+
exports.formatUserOrGetUserById = formatUserOrGetUserById;
|
|
18
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":";;;AAGA,SAAS,gBAAgB,CAAC,IAAoC;;IAC1D,OAAO,IAAI,CAAC,SAAS,KAAI,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA,IAAI,IAAI,CAAC,IAAI,CAAC;AACnE,CAAC;AAcG,4CAAgB;AAZpB,MAAa,8BAA8B;IAA3C;QACI,mBAAc,GAAY,qBAAqB,CAAA;IAInD,CAAC;CAAA;AALD,wEAKC;AACD,SAAS,uBAAuB,CAAC,OAAuC;AAExE,CAAC;AAKG,0DAAuB"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axios.js","sourceRoot":"","sources":["../../src/http/axios.ts"],"names":[],"mappings":""}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { logger, Logger, LoggerProps } from "./logger/logger";
|
|
3
|
+
import { LOG_LEVEL, LoggerInterface } from "./logger";
|
|
4
|
+
import { NullLogger } from "./logger/null-logger";
|
|
5
|
+
import * as middlewares from "./middlewares";
|
|
6
|
+
import * as helpers from "./helpers";
|
|
7
|
+
import * as responses from "./responses";
|
|
8
|
+
import * as databases from "./database";
|
|
9
|
+
import * as brokers from "./brokers";
|
|
10
|
+
import * as monitoring from "./monitoring";
|
|
11
|
+
import * as secrets from "./secrets";
|
|
12
|
+
import * as exceptions from "./exceptions/custom.exception";
|
|
13
|
+
import * as translations from "./translations";
|
|
14
|
+
import actions from "./actions";
|
|
15
|
+
import * as types from "./types";
|
|
16
|
+
declare const dayjs: typeof helpers.dayjs;
|
|
17
|
+
export { axios, logger, actions, dayjs, databases, responses, helpers, middlewares, translations, brokers, Logger, NullLogger, LoggerProps, LoggerInterface, LOG_LEVEL, monitoring, secrets, exceptions, types };
|