drapcode-utility 1.1.6 → 1.1.7

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.
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -35,17 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
38
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.decryptDataKey = exports.createKMSDataKey = exports.crypt = void 0;
43
- var aws_sdk_1 = require("aws-sdk");
44
- var crypto_1 = __importDefault(require("crypto"));
45
- var prefix = "rec";
46
- var randomCharLen = 8;
39
+ exports.drapcodeEncryptDecrypt = exports.decryptDataWithKMS = exports.encryptDataWithKMS = exports.createKMSDataKey = exports.processDataEncryptionDecryption = exports.processItemEncryptDecrypt = exports.crypt = void 0;
40
+ var crypt_1 = require("./crypt");
41
+ var KMS_1 = require("./KMS");
47
42
  var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
48
- var _a, accessKeyId, secretAccessKey, region, config, key, promises;
43
+ var _a, accessKeyId, secretAccessKey, region, config, plainTextData, promises;
49
44
  return __generator(this, function (_b) {
50
45
  switch (_b.label) {
51
46
  case 0:
@@ -53,26 +48,27 @@ var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void
53
48
  _a = encryption.awsConfig, accessKeyId = _a.accessKeyId, secretAccessKey = _a.secretAccessKey, region = _a.region;
54
49
  config = {
55
50
  region: region,
56
- credentials: {
57
- accessKeyId: accessKeyId,
58
- secretAccessKey: secretAccessKey,
59
- },
51
+ accessKeyId: accessKeyId,
52
+ secretAccessKey: secretAccessKey,
60
53
  };
61
- return [4 /*yield*/, exports.decryptDataKey(encryption.key, config)];
54
+ return [4 /*yield*/, (0, KMS_1.processKMSDecryption)(config, encryption.dataKey, {})];
62
55
  case 1:
63
- key = _b.sent();
64
- encryption.key = key.toString("base64");
56
+ plainTextData = _b.sent();
57
+ if (plainTextData.status === "FAILED") {
58
+ return [2 /*return*/, plainTextData];
59
+ }
60
+ encryption.dataKey = plainTextData.data;
65
61
  _b.label = 2;
66
62
  case 2:
67
63
  if (!Array.isArray(data)) return [3 /*break*/, 4];
68
64
  promises = data.map(function (item) {
69
- return cryptItem(item, fields, encryption, decrypt);
65
+ return (0, exports.processItemEncryptDecrypt)(item, fields, encryption, decrypt);
70
66
  });
71
67
  return [4 /*yield*/, Promise.all(promises)];
72
68
  case 3:
73
69
  data = _b.sent();
74
70
  return [3 /*break*/, 6];
75
- case 4: return [4 /*yield*/, cryptItem(data, fields, encryption, decrypt)];
71
+ case 4: return [4 /*yield*/, (0, exports.processItemEncryptDecrypt)(data, fields, encryption, decrypt)];
76
72
  case 5:
77
73
  data = _b.sent();
78
74
  _b.label = 6;
@@ -81,177 +77,190 @@ var crypt = function (data, fields, encryption, decrypt) { return __awaiter(void
81
77
  });
82
78
  }); };
83
79
  exports.crypt = crypt;
84
- var cryptItem = function (item, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
85
- return __generator(this, function (_a) {
86
- if (item && typeof item === "object") {
87
- Object.keys(item).forEach(function (fieldName) { return __awaiter(void 0, void 0, void 0, function () {
88
- var field, _a, _b;
89
- return __generator(this, function (_c) {
90
- switch (_c.label) {
91
- case 0:
92
- field = fields.find(function (field) { return field.fieldName === fieldName; });
93
- if (!(field && field.encrypted)) return [3 /*break*/, 2];
94
- _a = item;
95
- _b = fieldName;
96
- return [4 /*yield*/, cryptData(item[fieldName], encryption, decrypt)];
97
- case 1:
98
- _a[_b] = _c.sent();
99
- _c.label = 2;
100
- case 2: return [2 /*return*/];
101
- }
102
- });
103
- }); });
80
+ var processItemEncryptDecrypt = function (item, fields, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
81
+ var _loop_1, _i, _a, fieldName;
82
+ return __generator(this, function (_b) {
83
+ switch (_b.label) {
84
+ case 0:
85
+ if (!(item && typeof item === "object")) return [3 /*break*/, 4];
86
+ _loop_1 = function (fieldName) {
87
+ var field, _c, _d;
88
+ return __generator(this, function (_e) {
89
+ switch (_e.label) {
90
+ case 0:
91
+ field = fields.find(function (field) { return field.fieldName === fieldName; });
92
+ if (!(field && field.encrypted)) return [3 /*break*/, 2];
93
+ _c = item;
94
+ _d = fieldName;
95
+ return [4 /*yield*/, (0, exports.processDataEncryptionDecryption)(item[fieldName], encryption, decrypt)];
96
+ case 1:
97
+ _c[_d] = _e.sent();
98
+ _e.label = 2;
99
+ case 2: return [2 /*return*/];
100
+ }
101
+ });
102
+ };
103
+ _i = 0, _a = Object.keys(item);
104
+ _b.label = 1;
105
+ case 1:
106
+ if (!(_i < _a.length)) return [3 /*break*/, 4];
107
+ fieldName = _a[_i];
108
+ return [5 /*yield**/, _loop_1(fieldName)];
109
+ case 2:
110
+ _b.sent();
111
+ _b.label = 3;
112
+ case 3:
113
+ _i++;
114
+ return [3 /*break*/, 1];
115
+ case 4: return [2 /*return*/, item];
104
116
  }
105
- return [2 /*return*/, item];
106
117
  });
107
118
  }); };
108
- var cryptData = function (data, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
109
- var encryptionType, algorithm, key, _a, _b;
119
+ exports.processItemEncryptDecrypt = processItemEncryptDecrypt;
120
+ var processDataEncryptionDecryption = function (data, encryption, decrypt) { return __awaiter(void 0, void 0, void 0, function () {
121
+ var encryptionType, dataKey, _a, result, _b;
110
122
  return __generator(this, function (_c) {
111
123
  switch (_c.label) {
112
124
  case 0:
113
- encryptionType = encryption.encryptionType, algorithm = encryption.algorithm, key = encryption.key;
125
+ encryptionType = encryption.encryptionType, dataKey = encryption.dataKey;
114
126
  if (!data)
115
127
  return [2 /*return*/, data];
116
128
  _a = encryptionType;
117
129
  switch (_a) {
118
- case "BASE64": return [3 /*break*/, 1];
119
- case "CUSTOM": return [3 /*break*/, 2];
120
- case "KMS": return [3 /*break*/, 3];
130
+ case "KMS": return [3 /*break*/, 1];
121
131
  }
122
- return [3 /*break*/, 8];
123
- case 1: return [2 /*return*/, decrypt ? decryptBase64(data) : encryptBase64(data)];
124
- case 2: return [2 /*return*/, decrypt
125
- ? decryptCustom(data, algorithm, key)
126
- : encryptCustom(data, algorithm, key)];
127
- case 3:
128
- if (!decrypt) return [3 /*break*/, 5];
129
- return [4 /*yield*/, decryptWithKMS(data, algorithm, key)];
130
- case 4:
132
+ return [3 /*break*/, 6];
133
+ case 1:
134
+ if (!decrypt) return [3 /*break*/, 3];
135
+ return [4 /*yield*/, (0, crypt_1.decryptData)(data, dataKey)];
136
+ case 2:
131
137
  _b = _c.sent();
132
- return [3 /*break*/, 7];
133
- case 5: return [4 /*yield*/, encryptWithKMS(data, algorithm, key)];
134
- case 6:
138
+ return [3 /*break*/, 5];
139
+ case 3: return [4 /*yield*/, (0, crypt_1.encryptData)(data, dataKey)];
140
+ case 4:
135
141
  _b = _c.sent();
136
- _c.label = 7;
137
- case 7: return [2 /*return*/, _b];
138
- case 8: return [2 /*return*/, data];
142
+ _c.label = 5;
143
+ case 5:
144
+ result = _b;
145
+ return [2 /*return*/, result];
146
+ case 6: return [2 /*return*/, data];
139
147
  }
140
148
  });
141
149
  }); };
142
- var encryptBase64 = function (data) {
143
- if (data.startsWith(prefix))
144
- return data;
145
- var randomFront = getRandomAlphaNumeric(randomCharLen);
146
- var randomback = getRandomAlphaNumeric(randomCharLen);
147
- var base64Data = btoa(data);
148
- return prefix + randomFront + base64Data + randomback;
149
- };
150
- var decryptBase64 = function (encryptedData) {
151
- if (encryptedData.startsWith(prefix)) {
152
- encryptedData = encryptedData.replace(prefix, "");
153
- encryptedData = encryptedData.substring(randomCharLen, encryptedData.length - randomCharLen);
154
- encryptedData = atob(encryptedData);
155
- }
156
- return encryptedData;
157
- };
158
- var encryptCustom = function (data, alogrithm, key) {
159
- return data;
160
- };
161
- var decryptCustom = function (encryptedData, alogrithm, key) {
162
- return encryptedData;
163
- };
164
- var getRandomAlphaNumeric = function (length) {
165
- return Math.random().toString(36).substr(2, length);
166
- };
167
- var createKMSDataKey = function (awsConfig, KeyId) { return __awaiter(void 0, void 0, void 0, function () {
168
- var kms_1;
150
+ exports.processDataEncryptionDecryption = processDataEncryptionDecryption;
151
+ /**
152
+ * This method is used to generate private KEY for KMS ARN
153
+ * It requires KMS config and ARN
154
+ * @param config AWS config
155
+ * @param arn KMS Key
156
+ * @returns {status: string, dataKey: string, message: ""}
157
+ */
158
+ var createKMSDataKey = function (config, arn) { return __awaiter(void 0, void 0, void 0, function () {
159
+ var dataKeyRes;
169
160
  return __generator(this, function (_a) {
170
- try {
171
- kms_1 = new aws_sdk_1.KMS(awsConfig);
172
- return [2 /*return*/, new Promise(function (resolve, reject) {
173
- var params = {
174
- KeyId: KeyId,
175
- KeySpec: "AES_256",
176
- };
177
- kms_1.generateDataKey(params, function (err, data) {
178
- if (err) {
179
- console.log("\n Error", err);
180
- reject(err);
181
- }
182
- else {
183
- resolve(data);
184
- }
185
- });
186
- })];
187
- }
188
- catch (error) {
189
- console.log("\n Error: ", error);
161
+ switch (_a.label) {
162
+ case 0: return [4 /*yield*/, (0, KMS_1.processKMSGenerateDataKey)(config, arn)];
163
+ case 1:
164
+ dataKeyRes = _a.sent();
165
+ return [2 /*return*/, dataKeyRes];
190
166
  }
191
- return [2 /*return*/];
192
167
  });
193
168
  }); };
194
169
  exports.createKMSDataKey = createKMSDataKey;
195
- var decryptDataKey = function (dataKey, awsConfig) { return __awaiter(void 0, void 0, void 0, function () {
196
- var kms_2, CiphertextBlob_1;
170
+ /**
171
+ * This method is used to encrypt plaintext upto 4KB
172
+ * It requires KMS config and ARN
173
+ * @param config AWS Config
174
+ * @param arn KMS Key
175
+ * @param plainText Text to be encrypted
176
+ * @param context Extra setting for extra security
177
+ * @returns {status: string, message: string, cipherText: string}
178
+ */
179
+ var encryptDataWithKMS = function (config, arn, plainText, context) { return __awaiter(void 0, void 0, void 0, function () {
180
+ var cryptData;
197
181
  return __generator(this, function (_a) {
198
- try {
199
- kms_2 = new aws_sdk_1.KMS(awsConfig);
200
- CiphertextBlob_1 = Buffer.from(dataKey, "base64");
201
- return [2 /*return*/, new Promise(function (resolve, reject) {
202
- var params = { CiphertextBlob: CiphertextBlob_1 };
203
- kms_2.decrypt(params, function (err, data) {
204
- if (err) {
205
- console.log("\n Error", err);
206
- reject(err);
207
- }
208
- else {
209
- resolve(data.Plaintext);
210
- }
211
- });
212
- })];
213
- }
214
- catch (error) {
215
- console.log("\n Error: ", error);
182
+ switch (_a.label) {
183
+ case 0: return [4 /*yield*/, (0, KMS_1.processKMSEncryption)(config, arn, plainText, context)];
184
+ case 1:
185
+ cryptData = _a.sent();
186
+ return [2 /*return*/, cryptData];
216
187
  }
217
- return [2 /*return*/];
218
188
  });
219
189
  }); };
220
- exports.decryptDataKey = decryptDataKey;
221
- var encryptWithKMS = function (data, algorithm, key) { return __awaiter(void 0, void 0, void 0, function () {
222
- var iv, keyBuffer, cipher, encryptedDataBuffer;
190
+ exports.encryptDataWithKMS = encryptDataWithKMS;
191
+ /**
192
+ * This method is used to decrypt secure text
193
+ * It requires KMS config
194
+ * @param config AWS Config
195
+ * @param cipherText Encrypted Text
196
+ * @param context Extra setting which given for extra security
197
+ * @returns {status: string, message: string, plainText: string}
198
+ */
199
+ var decryptDataWithKMS = function (config, cipherText, context) { return __awaiter(void 0, void 0, void 0, function () {
200
+ var plainTextData;
223
201
  return __generator(this, function (_a) {
224
- try {
225
- iv = Buffer.from("i4mboZDwaNEC38YCzi77lw==", "base64");
226
- keyBuffer = Buffer.from(key, "base64");
227
- cipher = crypto_1.default.createCipheriv(algorithm, keyBuffer, iv);
228
- encryptedDataBuffer = cipher.update(data);
229
- encryptedDataBuffer = Buffer.concat([encryptedDataBuffer, cipher.final()]);
230
- return [2 /*return*/, encryptedDataBuffer.toString("base64")];
231
- }
232
- catch (error) {
233
- console.log("\n Error: ", error);
234
- return [2 /*return*/, data];
202
+ switch (_a.label) {
203
+ case 0: return [4 /*yield*/, (0, KMS_1.processKMSDecryption)(config, cipherText, context)];
204
+ case 1:
205
+ plainTextData = _a.sent();
206
+ return [2 /*return*/, plainTextData];
235
207
  }
236
- return [2 /*return*/];
237
208
  });
238
209
  }); };
239
- var decryptWithKMS = function (data, algorithm, key) { return __awaiter(void 0, void 0, void 0, function () {
240
- var iv, encryptedData, keyBuffer, decipher, decryptedBuffer;
210
+ exports.decryptDataWithKMS = decryptDataWithKMS;
211
+ var drapcodeEncryptDecrypt = function (data, encrypt) { return __awaiter(void 0, void 0, void 0, function () {
212
+ var region, accessKey, secretKey, privateDataKey, config, plainTextData, publicKey, response;
241
213
  return __generator(this, function (_a) {
242
- try {
243
- iv = Buffer.from("i4mboZDwaNEC38YCzi77lw==", "base64");
244
- encryptedData = Buffer.from(data, "base64");
245
- keyBuffer = Buffer.from(key, "base64");
246
- decipher = crypto_1.default.createDecipheriv(algorithm, keyBuffer, iv);
247
- decryptedBuffer = decipher.update(encryptedData);
248
- decryptedBuffer = Buffer.concat([decryptedBuffer, decipher.final()]);
249
- return [2 /*return*/, decryptedBuffer.toString()];
250
- }
251
- catch (error) {
252
- console.log("\n Error: ", error);
253
- return [2 /*return*/, data];
214
+ switch (_a.label) {
215
+ case 0:
216
+ region = process.env.AWS_KMS_REGION;
217
+ accessKey = process.env.AWS_KMS_ACCESS_KEY;
218
+ secretKey = process.env.AWS_KMS_SECRET_KEY;
219
+ privateDataKey = process.env.AWS_KMS_PRIVATE_DATA_KEY;
220
+ if (!region)
221
+ return [2 /*return*/, { status: "FAILED", message: "AWS Region is missing", data: "" }];
222
+ if (!accessKey)
223
+ return [2 /*return*/, { status: "FAILED", message: "AWS Access Key is missing", data: "" }];
224
+ if (!secretKey)
225
+ return [2 /*return*/, {
226
+ status: "FAILED",
227
+ message: "AWS Access Secret Key is missing",
228
+ data: "",
229
+ }];
230
+ if (!privateDataKey)
231
+ return [2 /*return*/, {
232
+ status: "FAILED",
233
+ message: "KMS Private Key is missing",
234
+ data: "",
235
+ }];
236
+ console.log("privateDataKey", privateDataKey);
237
+ config = {
238
+ region: region,
239
+ accessKeyId: accessKey,
240
+ secretAccessKey: secretKey,
241
+ };
242
+ return [4 /*yield*/, (0, KMS_1.processKMSDecryption)(config, privateDataKey, {})];
243
+ case 1:
244
+ plainTextData = _a.sent();
245
+ if (plainTextData.status === "FAILED") {
246
+ return [2 /*return*/, plainTextData];
247
+ }
248
+ publicKey = plainTextData.data;
249
+ response = null;
250
+ if (!encrypt) return [3 /*break*/, 3];
251
+ console.log("Encrypting");
252
+ return [4 /*yield*/, (0, crypt_1.encryptData)(data, publicKey)];
253
+ case 2:
254
+ response = _a.sent();
255
+ return [3 /*break*/, 5];
256
+ case 3:
257
+ console.log("Decrypting");
258
+ return [4 /*yield*/, (0, crypt_1.decryptData)(data, publicKey)];
259
+ case 4:
260
+ response = _a.sent();
261
+ _a.label = 5;
262
+ case 5: return [2 /*return*/, { status: "SUCCESS", message: "", data: response }];
254
263
  }
255
- return [2 /*return*/];
256
264
  });
257
265
  }); };
266
+ exports.drapcodeEncryptDecrypt = drapcodeEncryptDecrypt;
@@ -0,0 +1,11 @@
1
+ export type AwsConfig = {
2
+ accessKeyId: string;
3
+ secretAccessKey: string;
4
+ region: string;
5
+ };
6
+ export type Encryption = {
7
+ encryptionType: string;
8
+ algorithm: string;
9
+ dataKey: string;
10
+ awsConfig: AwsConfig;
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/build/index.d.ts CHANGED
@@ -6,7 +6,6 @@ export * from "./errors/axios-error";
6
6
  export * from "./middlewares/error-logger";
7
7
  export * from "./middlewares/interceptor-logger";
8
8
  export * from "./middlewares/interceptor-logger-new";
9
- export * from "./middlewares/api-limiter";
10
9
  export * from "./utils/date-util";
11
10
  export * from "./utils/query-parser";
12
11
  export * from "./utils/query-paser-new";
package/build/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -18,7 +22,6 @@ __exportStar(require("./errors/axios-error"), exports);
18
22
  __exportStar(require("./middlewares/error-logger"), exports);
19
23
  __exportStar(require("./middlewares/interceptor-logger"), exports);
20
24
  __exportStar(require("./middlewares/interceptor-logger-new"), exports);
21
- __exportStar(require("./middlewares/api-limiter"), exports);
22
25
  __exportStar(require("./utils/date-util"), exports);
23
26
  __exportStar(require("./utils/query-parser"), exports);
24
27
  __exportStar(require("./utils/query-paser-new"), exports);
@@ -32,16 +32,16 @@ var errorLogger = function (err, req, res, next) {
32
32
  var originalUrl = req.originalUrl, method = req.method, body = req.body, params = req.params, query = req.query, db = req.db, projectName = req.projectName, projectId = req.projectId, ip = req.ip;
33
33
  var PreviouseFilePath;
34
34
  if (projectName) {
35
- loggerPath = loggerPath + "/" + projectName + "/" + date_util_1.createLoggerDateFormat() + "/output";
36
- PreviouseFilePath = loggerPath + "/" + projectName + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
35
+ loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
36
+ PreviouseFilePath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
37
37
  }
38
38
  else if (projectId) {
39
- loggerPath = loggerPath + "/" + projectId + "/" + date_util_1.createLoggerDateFormat() + "/output";
40
- PreviouseFilePath = loggerPath + "/" + projectId + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
39
+ loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
40
+ PreviouseFilePath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
41
41
  }
42
42
  else {
43
- loggerPath = loggerPath + "/" + date_util_1.createLoggerDateFormat() + "/output";
44
- PreviouseFilePath = loggerPath + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
43
+ loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
44
+ PreviouseFilePath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
45
45
  }
46
46
  if (fs_1.default.existsSync(PreviouseFilePath)) {
47
47
  fs_1.default.rmSync(PreviouseFilePath, { recursive: true, force: true });
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.interceptLoggerNew = void 0;
7
7
  var drapcode_logger_1 = require("drapcode-logger");
8
8
  var date_util_1 = require("../utils/date-util");
9
- // import { saveRequest } from "./redis/request-log";
10
9
  var fs_1 = __importDefault(require("fs"));
11
10
  var interceptLoggerNew = function (req, res, next) {
12
11
  var todayFilePath = "/tmp/log";
@@ -28,16 +27,16 @@ var interceptLoggerNew = function (req, res, next) {
28
27
  }
29
28
  var PreviouseFilePath;
30
29
  if (projectName) {
31
- loggerPath = loggerPath + "/" + projectName + "/" + date_util_1.createLoggerDateFormat() + "/output";
32
- PreviouseFilePath = loggerPath + "/" + projectName + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
30
+ loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
31
+ PreviouseFilePath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
33
32
  }
34
33
  else if (projectId) {
35
- loggerPath = loggerPath + "/" + projectId + "/" + date_util_1.createLoggerDateFormat() + "/output";
36
- PreviouseFilePath = loggerPath + "/" + projectId + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
34
+ loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
35
+ PreviouseFilePath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
37
36
  }
38
37
  else {
39
- loggerPath = loggerPath + "/" + date_util_1.createLoggerDateFormat() + "/output";
40
- PreviouseFilePath = loggerPath + "/" + date_util_1.createLoggerPreviouseDateFormat() + "/";
38
+ loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)(), "/output");
39
+ PreviouseFilePath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerPreviouseDateFormat)(), "/");
41
40
  }
42
41
  if (fs_1.default.existsSync(PreviouseFilePath)) {
43
42
  fs_1.default.rmSync(PreviouseFilePath, { recursive: true, force: true });
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.interceptLogger = void 0;
4
4
  var drapcode_logger_1 = require("drapcode-logger");
5
5
  var date_util_1 = require("../utils/date-util");
6
- // import { saveRequest } from "./redis/request-log";
7
6
  var interceptLogger = function (req, res, next) {
8
7
  var loggerPath = process.env.LOG_FOLDER_PATH || "/tmp/logs";
9
8
  var originalUrl = req.originalUrl, method = req.method, body = req.body, params = req.params, query = req.query, db = req.db, projectName = req.projectName, projectId = req.projectId, ip = req.ip;
@@ -22,13 +21,13 @@ var interceptLogger = function (req, res, next) {
22
21
  reqObject["dbName"] = db.name;
23
22
  }
24
23
  if (projectName) {
25
- loggerPath = loggerPath + "/" + projectName + "/" + date_util_1.createLoggerDateFormat();
24
+ loggerPath = "".concat(loggerPath, "/").concat(projectName, "/").concat((0, date_util_1.createLoggerDateFormat)());
26
25
  }
27
26
  else if (projectId) {
28
- loggerPath = loggerPath + "/" + projectId + "/" + date_util_1.createLoggerDateFormat();
27
+ loggerPath = "".concat(loggerPath, "/").concat(projectId, "/").concat((0, date_util_1.createLoggerDateFormat)());
29
28
  }
30
29
  else {
31
- loggerPath = loggerPath + "/" + date_util_1.createLoggerDateFormat();
30
+ loggerPath = "".concat(loggerPath, "/").concat((0, date_util_1.createLoggerDateFormat)());
32
31
  }
33
32
  var logger = new drapcode_logger_1.FileLogger(loggerPath).createLogger();
34
33
  var oldSend = res.send;
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -47,7 +47,7 @@ var saveRequest = function (req, res) {
47
47
  return __generator(this, function (_a) {
48
48
  switch (_a.label) {
49
49
  case 0:
50
- req.body = util_1.isEmpty(req.body) ? req.query : req.body;
50
+ req.body = (0, util_1.isEmpty)(req.body) ? req.query : req.body;
51
51
  ip = req.headers["x-forwarded-for"] ||
52
52
  req.connection.remoteAddress ||
53
53
  req.socket.remoteAddress ||
@@ -62,13 +62,13 @@ var saveRequest = function (req, res) {
62
62
  response: JSON.stringify(res),
63
63
  ipAddress: ip,
64
64
  };
65
- return [4 /*yield*/, drapcode_redis_1.redis_get_method("requestLog")];
65
+ return [4 /*yield*/, (0, drapcode_redis_1.redis_get_method)("requestLog")];
66
66
  case 1:
67
67
  redisData = _a.sent();
68
68
  if (!redisData)
69
69
  redisData = [];
70
70
  redisData.push(respObj);
71
- return [4 /*yield*/, drapcode_redis_1.redis_set_method("requestLog", redisData)];
71
+ return [4 /*yield*/, (0, drapcode_redis_1.redis_set_method)("requestLog", redisData)];
72
72
  case 2:
73
73
  _a.sent();
74
74
  return [2 /*return*/];
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -35,10 +35,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
39
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
40
- to[j] = from[i];
41
- return to;
38
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
+ if (ar || !(i in from)) {
41
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
+ ar[i] = from[i];
43
+ }
44
+ }
45
+ return to.concat(ar || Array.prototype.slice.call(from));
42
46
  };
43
47
  var __importDefault = (this && this.__importDefault) || function (mod) {
44
48
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -114,7 +118,7 @@ var handleMultErrorConfig = function (error, result, status) {
114
118
  var apiErrorMessage;
115
119
  var apiErrorValue;
116
120
  if (result && result !== "undefined" && result !== "null") {
117
- console.log("handleMultErrorConfig result :>> " + Object.keys(result));
121
+ console.log("handleMultErrorConfig result :>> ".concat(Object.keys(result)));
118
122
  apiErrorMessage = lodash_1.default.get(result, message);
119
123
  if (apiErrorMessage) {
120
124
  console.log("*** utility 3 ***");
@@ -144,7 +148,7 @@ var handleMultErrorConfig = function (error, result, status) {
144
148
  apiErrorValue = status;
145
149
  }
146
150
  console.log("apiErrorValue", apiErrorValue);
147
- apiErrorValue = "" + apiErrorValue;
151
+ apiErrorValue = "".concat(apiErrorValue);
148
152
  console.log("apiErrorMessage", apiErrorMessage);
149
153
  console.log("apiErrorValue", apiErrorValue);
150
154
  if (value && apiErrorValue == value) {
@@ -181,7 +185,7 @@ var nestedValue = function (data, messages) {
181
185
  messages.push(value);
182
186
  }
183
187
  else if (Array.isArray(value)) {
184
- messages = __spreadArray(__spreadArray([], messages), value);
188
+ messages = __spreadArray(__spreadArray([], messages, true), value, true);
185
189
  }
186
190
  else {
187
191
  if (Object.keys(value).length) {