@creator.co/wapi 1.4.0 → 1.5.1
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/dist/index.d.ts +22 -14
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/Cache/Redis.d.ts +34 -0
- package/dist/src/Cache/Redis.js +127 -0
- package/dist/src/Cache/Redis.js.map +1 -0
- package/dist/src/Cache/types.d.ts +30 -0
- package/dist/src/Cache/types.js +3 -0
- package/dist/src/Cache/types.js.map +1 -0
- package/dist/src/Database/DatabaseManager.d.ts +1 -6
- package/dist/src/Database/DatabaseManager.js +1 -1
- package/dist/src/Database/DatabaseManager.js.map +1 -1
- package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +2 -2
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
- package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +5 -6
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
- package/dist/src/Logger/Logger.d.ts +2 -0
- package/dist/src/Logger/Logger.js +19 -7
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Server/lib/Server.js +0 -1
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/index.ts +22 -13
- package/package.json +2 -1
- package/src/Cache/Redis.ts +65 -0
- package/src/Cache/types.ts +32 -0
- package/src/Database/DatabaseManager.ts +1 -1
- package/src/Database/integrations/knex/KnexDatabase.ts +1 -1
- package/src/Database/integrations/kysely/KyselyDatabase.ts +4 -4
- package/src/Database/integrations/pgsql/PostgresDatabase.ts +1 -1
- package/src/Logger/Logger.ts +18 -7
- package/src/Server/lib/Server.ts +0 -1
- package/tests/Cache/Redis.test.ts +98 -0
- package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +8 -5
- package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +1 -1
- package/tests/Logger/Logger.test.ts +61 -5
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import Utils from './src/API/Utils';
|
|
|
4
4
|
import EventProcessor from './src/BaseEvent/EventProcessor';
|
|
5
5
|
import Process from './src/BaseEvent/Process';
|
|
6
6
|
import Transaction from './src/BaseEvent/Transaction';
|
|
7
|
+
import Redis from './src/Cache/Redis';
|
|
7
8
|
import Configuration from './src/Config/Configuration';
|
|
8
9
|
import Crypto from './src/Crypto/Crypto';
|
|
9
10
|
import JWT from './src/Crypto/JWT';
|
|
@@ -11,18 +12,25 @@ import * as Database from './src/Database';
|
|
|
11
12
|
import Mailer from './src/Mailer/Mailer';
|
|
12
13
|
import Router, { Route } from './src/Server/Router';
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
15
|
+
* This module exports various classes and utilities for handling transactions, processes, events, routing,
|
|
16
|
+
* mailing, cryptography, JWT, configuration, Redis, responses, utilities, routes, response error types,
|
|
17
|
+
* HTTP methods, and databases.
|
|
18
|
+
* @exports {
|
|
19
|
+
* Transaction,
|
|
20
|
+
* Process,
|
|
21
|
+
* EventProcessor,
|
|
22
|
+
* Router,
|
|
23
|
+
* Mailer,
|
|
24
|
+
* Crypto,
|
|
25
|
+
* JWT,
|
|
26
|
+
* Configuration,
|
|
27
|
+
* Redis,
|
|
28
|
+
* Response,
|
|
29
|
+
* Utils,
|
|
30
|
+
* Route,
|
|
31
|
+
* ResponseErrorType,
|
|
32
|
+
* HttpMethod,
|
|
33
|
+
* Database,
|
|
34
|
+
* }
|
|
27
35
|
*/
|
|
28
|
-
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Response, Utils, Route, ResponseErrorType, HttpMethod, Database, };
|
|
36
|
+
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Redis, Response, Utils, Route, ResponseErrorType, HttpMethod, Database, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Database = exports.HttpMethod = exports.Utils = exports.Response = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
|
|
3
|
+
exports.Database = exports.HttpMethod = exports.Utils = exports.Response = exports.Redis = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
|
|
4
4
|
var Request_1 = require("./src/API/Request");
|
|
5
5
|
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return Request_1.HttpMethod; } });
|
|
6
6
|
var Response_1 = require("./src/API/Response");
|
|
@@ -13,6 +13,8 @@ var Process_1 = require("./src/BaseEvent/Process");
|
|
|
13
13
|
exports.Process = Process_1.default;
|
|
14
14
|
var Transaction_1 = require("./src/BaseEvent/Transaction");
|
|
15
15
|
exports.Transaction = Transaction_1.default;
|
|
16
|
+
var Redis_1 = require("./src/Cache/Redis");
|
|
17
|
+
exports.Redis = Redis_1.default;
|
|
16
18
|
var Configuration_1 = require("./src/Config/Configuration");
|
|
17
19
|
exports.Configuration = Configuration_1.default;
|
|
18
20
|
var Crypto_1 = require("./src/Crypto/Crypto");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAuD5C,2FAvDO,oBAAU,OAuDP;AAtDZ,+CAAgE;AAgD9D,mBAhDK,kBAAQ,CAgDL;AA/CV,yCAAmC;AAiDjC,gBAjDK,eAAK,CAiDL;AAhDP,iEAA2D;AAqCzD,yBArCK,wBAAc,CAqCL;AApChB,mDAA6C;AAmC3C,kBAnCK,iBAAO,CAmCL;AAlCT,2DAAqD;AAiCnD,sBAjCK,qBAAW,CAiCL;AAhCb,2CAAqC;AAyCnC,gBAzCK,eAAK,CAyCL;AAxCP,4DAAsD;AAuCpD,wBAvCK,uBAAa,CAuCL;AAtCf,8CAAwC;AAoCtC,iBApCK,gBAAM,CAoCL;AAnCR,wCAAkC;AAoChC,cApCK,aAAG,CAoCL;AAnCL,yCAA0C;AA8CxC,4BAAQ;AA7CV,8CAAwC;AAgCtC,iBAhCK,gBAAM,CAgCL;AA/BR,8CAAmD;AA6BjD,iBA7BK,gBAAM,CA6BL"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creator.co/wapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"parse-duration": "^1.1.0",
|
|
42
42
|
"path-to-regexp": "^6.2.1",
|
|
43
43
|
"pg": "^8.11.3",
|
|
44
|
+
"redis": "^4.6.13",
|
|
44
45
|
"sha1": "^1.1.1",
|
|
45
46
|
"stack-trace": "0.0.10",
|
|
46
47
|
"zod": "^3.22.4"
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RedisClientType } from 'redis';
|
|
2
|
+
import { CacheConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a Redis cache connection class.
|
|
5
|
+
*/
|
|
6
|
+
export default class Redis {
|
|
7
|
+
/**
|
|
8
|
+
* Private static property that holds the connection to a Redis client.
|
|
9
|
+
* @type {RedisClientType}
|
|
10
|
+
*/
|
|
11
|
+
private static _connection;
|
|
12
|
+
/**
|
|
13
|
+
* A private static property that holds a reference to the redis.createClient function.
|
|
14
|
+
* This property is used to create client.
|
|
15
|
+
*/
|
|
16
|
+
private static ClientFactory;
|
|
17
|
+
private static awaitingConnectionQueue;
|
|
18
|
+
/**
|
|
19
|
+
* Establishes a connection to a Redis cache based on the provided configuration.
|
|
20
|
+
* If a connection is already established, it returns the existing connection.
|
|
21
|
+
* If a connection is pending, it waits for the connection to be established and then returns it.
|
|
22
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to Redis cache.
|
|
23
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client once the connection is established.
|
|
24
|
+
*/
|
|
25
|
+
static connection(config: CacheConfig<'redis'>): Promise<RedisClientType>;
|
|
26
|
+
/**
|
|
27
|
+
* Establishes a connection to a Redis client based on the provided configuration
|
|
28
|
+
* and holds it for reusability. If connection is detected closed, new connection is
|
|
29
|
+
* initialized and established.
|
|
30
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to the Redis client.
|
|
31
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client connection.
|
|
32
|
+
*/
|
|
33
|
+
private static redisConnection;
|
|
34
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
var redis_1 = require("redis");
|
|
51
|
+
/**
|
|
52
|
+
* Represents a Redis cache connection class.
|
|
53
|
+
*/
|
|
54
|
+
var Redis = /** @class */ (function () {
|
|
55
|
+
function Redis() {
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Establishes a connection to a Redis cache based on the provided configuration.
|
|
59
|
+
* If a connection is already established, it returns the existing connection.
|
|
60
|
+
* If a connection is pending, it waits for the connection to be established and then returns it.
|
|
61
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to Redis cache.
|
|
62
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client once the connection is established.
|
|
63
|
+
*/
|
|
64
|
+
Redis.connection = function (config) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var con;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
// No connection, but waiting connection queue is valid? wait until other promise
|
|
71
|
+
// fulfill this promise
|
|
72
|
+
if (!Redis._connection && Redis.awaitingConnectionQueue) {
|
|
73
|
+
return [2 /*return*/, new Promise(function (resolve) { return Redis.awaitingConnectionQueue.push(resolve); })];
|
|
74
|
+
}
|
|
75
|
+
else if (Redis._connection)
|
|
76
|
+
return [2 /*return*/, Redis._connection
|
|
77
|
+
// Connect
|
|
78
|
+
]; //already connected
|
|
79
|
+
// Connect
|
|
80
|
+
Redis.awaitingConnectionQueue = [];
|
|
81
|
+
return [4 /*yield*/, Redis.redisConnection(config)];
|
|
82
|
+
case 1:
|
|
83
|
+
con = _a.sent();
|
|
84
|
+
if (Redis.awaitingConnectionQueue) {
|
|
85
|
+
Redis.awaitingConnectionQueue.forEach(function (resolve) { return resolve(con); });
|
|
86
|
+
}
|
|
87
|
+
Redis.awaitingConnectionQueue = null;
|
|
88
|
+
return [2 /*return*/, con];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Establishes a connection to a Redis client based on the provided configuration
|
|
95
|
+
* and holds it for reusability. If connection is detected closed, new connection is
|
|
96
|
+
* initialized and established.
|
|
97
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to the Redis client.
|
|
98
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client connection.
|
|
99
|
+
*/
|
|
100
|
+
Redis.redisConnection = function (config) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var connection;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
if (Redis._connection && Redis._connection.isOpen)
|
|
107
|
+
return [2 /*return*/, Redis._connection];
|
|
108
|
+
console.debug('Starting remote cache connection');
|
|
109
|
+
connection = Redis.ClientFactory(__assign(__assign({ username: config.username }, (config.password ? { password: config.password } : {})), { disableOfflineQueue: true, socket: __assign(__assign({ host: config.hostname }, (config.enableTLS ? { tls: true } : {})), { connectTimeout: 10000 }) }));
|
|
110
|
+
return [4 /*yield*/, connection.connect()];
|
|
111
|
+
case 1:
|
|
112
|
+
_a.sent();
|
|
113
|
+
Redis._connection = connection;
|
|
114
|
+
return [2 /*return*/, Redis._connection];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* A private static property that holds a reference to the redis.createClient function.
|
|
121
|
+
* This property is used to create client.
|
|
122
|
+
*/
|
|
123
|
+
Redis.ClientFactory = redis_1.createClient;
|
|
124
|
+
return Redis;
|
|
125
|
+
}());
|
|
126
|
+
exports.default = Redis;
|
|
127
|
+
//# sourceMappingURL=Redis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Redis.js","sourceRoot":"","sources":["../../../src/Cache/Redis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAqD;AAGrD;;GAEG;AACH;IAAA;IA0DA,CAAC;IA9CC;;;;;;OAMG;IACiB,gBAAU,GAA9B,UAA+B,MAA4B;;;;;;wBACzD,iFAAiF;wBACjF,uBAAuB;wBACvB,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,uBAAuB,EAAE,CAAC;4BACxD,sBAAO,IAAI,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,EAA3C,CAA2C,CAAC,EAAA;wBAC5E,CAAC;6BAAM,IAAI,KAAK,CAAC,WAAW;4BAAE,sBAAO,KAAK,CAAC,WAAW;gCACtD,UAAU;8BAD4C,CAAC,mBAAmB;wBAC1E,UAAU;wBACV,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAA;wBACtB,qBAAM,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,EAAA;;wBAAzC,GAAG,GAAG,SAAmC;wBAC/C,IAAI,KAAK,CAAC,uBAAuB,EAAE,CAAC;4BAClC,KAAK,CAAC,uBAAuB,CAAC,OAAO,CAAC,UAAA,OAAO,IAAI,OAAA,OAAO,CAAC,GAAG,CAAC,EAAZ,CAAY,CAAC,CAAA;wBAChE,CAAC;wBACD,KAAK,CAAC,uBAAuB,GAAG,IAAI,CAAA;wBACpC,sBAAO,GAAG,EAAA;;;;KACX;IACD;;;;;;OAMG;IACkB,qBAAe,GAApC,UAAqC,MAA4B;;;;;;wBAC/D,IAAI,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM;4BAAE,sBAAO,KAAK,CAAC,WAAW,EAAA;wBAC3E,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAA;wBAC3C,UAAU,GAAG,KAAK,CAAC,aAAa,qBACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ,IACtB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KACzD,mBAAmB,EAAE,IAAI,EACzB,MAAM,sBACJ,IAAI,EAAE,MAAM,CAAC,QAAQ,IAClB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAC1C,cAAc,EAAE,KAAK,OAEvB,CAAA;wBACF,qBAAM,UAAU,CAAC,OAAO,EAAE,EAAA;;wBAA1B,SAA0B,CAAA;wBAC1B,KAAK,CAAC,WAAW,GAAG,UAAiB,CAAA;wBACrC,sBAAO,KAAK,CAAC,WAAW,EAAA;;;;KACzB;IAnDD;;;OAGG;IACY,mBAAa,GAAG,oBAAY,CAAA;IAgD7C,YAAC;CAAA,AA1DD,IA0DC;kBA1DoB,KAAK"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Redis from './Redis';
|
|
2
|
+
/**
|
|
3
|
+
* Defines a type alias for specifying the cache type as 'redis'.
|
|
4
|
+
*/
|
|
5
|
+
export type CacheType = 'redis';
|
|
6
|
+
/**
|
|
7
|
+
* Defines a CacheClass type that has a 'redis' property which is a constructor function
|
|
8
|
+
* that takes in any number of arguments and returns an instance of Redis.
|
|
9
|
+
*/
|
|
10
|
+
export type CacheClass = {
|
|
11
|
+
redis: new (...args: any[]) => Redis;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Represents the base configuration for a cache, including host, username, password, and TLS settings.
|
|
15
|
+
*/
|
|
16
|
+
export type CacheBaseConfig = {
|
|
17
|
+
hostname: string;
|
|
18
|
+
username: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
enableTLS: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Defines a CacheConfig type that extends CacheBaseConfig and includes a specific cache type.
|
|
24
|
+
* @template S - The specific cache type to be included in the CacheConfig.
|
|
25
|
+
* @extends CacheBaseConfig
|
|
26
|
+
* @property {S} type - The specific cache type included in the CacheConfig.
|
|
27
|
+
*/
|
|
28
|
+
export type CacheConfig<S extends CacheType> = CacheBaseConfig & {
|
|
29
|
+
type: S;
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Cache/types.ts"],"names":[],"mappings":""}
|
|
@@ -12,12 +12,7 @@ import type { DatabaseImplType, DatabaseType, DbConfig } from './types';
|
|
|
12
12
|
export declare const DATABASES: {
|
|
13
13
|
knex: typeof KnexDatabase;
|
|
14
14
|
pg: typeof PostgresDatabase;
|
|
15
|
-
kysely:
|
|
16
|
-
new (config: DbConfig<"kysely">): KyselyDatabase<any>;
|
|
17
|
-
kyselyPgProvider: typeof import("kysely").PostgresDialect;
|
|
18
|
-
kyselyProvider: typeof import("kysely").Kysely;
|
|
19
|
-
pgProvider: typeof import("pg").Pool;
|
|
20
|
-
};
|
|
15
|
+
kysely: typeof KyselyDatabase;
|
|
21
16
|
};
|
|
22
17
|
/**
|
|
23
18
|
* Manages the creation and storage of database instances.
|
|
@@ -15,7 +15,7 @@ var PostgresDatabase_1 = require("./integrations/pgsql/PostgresDatabase");
|
|
|
15
15
|
exports.DATABASES = {
|
|
16
16
|
knex: KnexDatabase_1.KnexDatabase,
|
|
17
17
|
pg: PostgresDatabase_1.PostgresDatabase,
|
|
18
|
-
kysely:
|
|
18
|
+
kysely: KyselyDatabase_1.KyselyDatabase,
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Manages the creation and storage of database instances.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,iEAA+D;AAC/D,uEAAqE;AACrE,0EAAwE;AAGxE;;;;;;GAMG;AACU,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,2BAAY;IAClB,EAAE,EAAE,mCAAgB;IACpB,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,iEAA+D;AAC/D,uEAAqE;AACrE,0EAAwE;AAGxE;;;;;;GAMG;AACU,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,2BAAY;IAClB,EAAE,EAAE,mCAAgB;IACpB,MAAM,EAAE,+BAAc;CACvB,CAAA;AAED;;GAEG;AACH;IAAA;QAME;;;WAGG;QACK,cAAS,GAAqB,iBAAS,CAAA;QAC/C;;;WAGG;QACK,cAAS,GAAgD,EAAE,CAAA;IA6BrE,CAAC;IA3BC;;;;OAIG;IACI,gCAAM,GAAb,UACE,MAAmB;QAEnB,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAQ,CAAA;QAC1C,CAAC;QACD,IAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAc,MAAa,CAAC,CAAA;QAC/D,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAA;QACrC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;;;OAIG;IACK,uCAAa,GAArB,UACE,MAA8D;QAE9D,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAa,CAAQ,CAAA;IAC9D,CAAC;IA1CD;;;OAGG;IACoB,wBAAQ,GAAG,IAAI,eAAe,EAAE,AAAxB,CAAwB;IAuCzD,sBAAC;CAAA,AA5CD,IA4CC;AA5CY,0CAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
2
|
import { KnexTransaction } from './KnexTransaction';
|
|
3
3
|
import { Database } from '../../Database';
|
|
4
4
|
import type { DbConfig } from '../../types';
|
|
@@ -11,7 +11,7 @@ export declare class KnexDatabase extends Database<KnexTransaction> {
|
|
|
11
11
|
* @param {knex.Knex.Config<any>} config - The configuration object for Knex.
|
|
12
12
|
* @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
|
|
13
13
|
*/
|
|
14
|
-
static knexProvider
|
|
14
|
+
private static knexProvider;
|
|
15
15
|
/**
|
|
16
16
|
* Represents a Knex client for interacting with a database.
|
|
17
17
|
* @type {Knex}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,gDAAiD;AAEjD,qDAAwE;AACxE,2CAAyC;AAGzC;;GAEG;AACH;IAAkC,gCAAyB;IAazD;;;;OAIG;IACH,sBAAmB,MAAwB;QACzC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QAEb,KAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;;IACvE,CAAC;IAED;;;;OAIG;IACK,sCAAe,GAAvB,UAAwB,MAAwB;QAC9C,IAAM,UAAU,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,CAAC;gBACN,GAAG,EAAE,MAAM,CAAC,cAAc;aAC3B;SACF,CAAA;QAED,OAAO,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACmB,kCAAW,GAAjC;;;;4BACS,qBAAM,qCAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAA;4BAAlE,sBAAO,SAA2D,EAAA;;;;KACnE;IArDD;;;;OAIG;
|
|
1
|
+
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,gDAAiD;AAEjD,qDAAwE;AACxE,2CAAyC;AAGzC;;GAEG;AACH;IAAkC,gCAAyB;IAazD;;;;OAIG;IACH,sBAAmB,MAAwB;QACzC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QAEb,KAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;;IACvE,CAAC;IAED;;;;OAIG;IACK,sCAAe,GAAvB,UAAwB,MAAwB;QAC9C,IAAM,UAAU,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,CAAC;gBACN,GAAG,EAAE,MAAM,CAAC,cAAc;aAC3B;SACF,CAAA;QAED,OAAO,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACmB,kCAAW,GAAjC;;;;4BACS,qBAAM,qCAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAA;4BAAlE,sBAAO,SAA2D,EAAA;;;;KACnE;IArDD;;;;OAIG;IACY,yBAAY,GAAiE,cAAI,CAAA;IAiDlG,mBAAC;CAAA,AAvDD,CAAkC,mBAAQ,GAuDzC;AAvDY,oCAAY"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Kysely
|
|
2
|
-
import { Pool } from 'pg';
|
|
1
|
+
import { Kysely } from 'kysely';
|
|
3
2
|
import { KyselyTransaction } from './KyselyTransaction';
|
|
4
3
|
import { Database } from '../../Database';
|
|
5
4
|
import type { DbConfig } from '../../types';
|
|
@@ -7,22 +6,22 @@ import type { DbConfig } from '../../types';
|
|
|
7
6
|
* Represents a database connection using the Kysely library with support for transactions.
|
|
8
7
|
* @template DBSchema - The schema type for the database.
|
|
9
8
|
*/
|
|
10
|
-
export declare class KyselyDatabase<DBSchema> extends Database<KyselyTransaction<DBSchema>> {
|
|
9
|
+
export declare class KyselyDatabase<DBSchema = never> extends Database<KyselyTransaction<DBSchema>> {
|
|
11
10
|
/**
|
|
12
11
|
* Represents a PostgreSQL provider for querying data using the PostgresDialect.
|
|
13
12
|
* @type {PostgresDialect}
|
|
14
13
|
*/
|
|
15
|
-
static kyselyPgProvider
|
|
14
|
+
private static kyselyPgProvider;
|
|
16
15
|
/**
|
|
17
16
|
* A public static property that provides access to the Kysely class.
|
|
18
17
|
* This property can be accessed without creating an instance of the class.
|
|
19
18
|
*/
|
|
20
|
-
static kyselyProvider
|
|
19
|
+
private static kyselyProvider;
|
|
21
20
|
/**
|
|
22
21
|
* A static property that represents a connection pool for PostgreSQL database connections.
|
|
23
22
|
* @type {Pool}
|
|
24
23
|
*/
|
|
25
|
-
static pgProvider
|
|
24
|
+
private static pgProvider;
|
|
26
25
|
/**
|
|
27
26
|
* Represents a PostgreSQL client using the PostgresDialect.
|
|
28
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiE;AACjE,yBAAyB;AAEzB,yDAA8E;AAC9E,2CAAyC;AAGzC;;;GAGG;AACH;
|
|
1
|
+
{"version":3,"file":"KyselyDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiE;AACjE,yBAAyB;AAEzB,yDAA8E;AAC9E,2CAAyC;AAGzC;;;GAGG;AACH;IAAsD,kCAAqC;IAmCzF;;;;OAIG;IACH,wBAAmB,MAA0B;QAC3C,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QACb,KAAI,CAAC,QAAQ,GAAG,KAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;QAC3C,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,eAAe,CAAC,KAAI,CAAC,QAAQ,CAAC,CAAA;QACjD,IAAI,MAAM,CAAC,WAAW,EA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* A public static property that represents a connection pool for a PostgreSQL database.
|
|
12
12
|
* This property is used to manage and provide connections to the PostgreSQL database.
|
|
13
13
|
*/
|
|
14
|
-
static pgProvider
|
|
14
|
+
private static pgProvider;
|
|
15
15
|
/**
|
|
16
16
|
* Represents a connection pool to manage multiple client connections to the database.
|
|
17
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyB;AAEzB,6DAAoF;AACpF,2CAAyC;AAGzC;;;GAGG;AACH;IAAsC,oCAA6B;IAgBjE;;;;OAIG;IACH,0BAAmB,MAAsB;QACvC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QACb,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,MAAM,CAAC,WAAW;YAAE,KAAI,CAAC,UAAU,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;;IACpF,CAAC;IAED;;;OAGG;IACmB,sCAAW,GAAjC;;;gBACE,sBAAO,6CAAuB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAA;;;KAClF;IACO,0CAAe,GAAvB,UAAwB,MAAoB;QAC1C,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,cAAc;SAC3B,CAAC,CAAA;IACJ,CAAC;IA1CD;;;OAGG;
|
|
1
|
+
{"version":3,"file":"PostgresDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyB;AAEzB,6DAAoF;AACpF,2CAAyC;AAGzC;;;GAGG;AACH;IAAsC,oCAA6B;IAgBjE;;;;OAIG;IACH,0BAAmB,MAAsB;QACvC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QACb,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,MAAM,CAAC,WAAW;YAAE,KAAI,CAAC,UAAU,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;;IACpF,CAAC;IAED;;;OAGG;IACmB,sCAAW,GAAjC;;;gBACE,sBAAO,6CAAuB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAA;;;KAClF;IACO,0CAAe,GAAvB,UAAwB,MAAoB;QAC1C,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC;YACrC,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,cAAc;SAC3B,CAAC,CAAA;IACJ,CAAC;IA1CD;;;OAGG;IACY,2BAAU,GAAG,SAAI,CAAA;IAuClC,uBAAC;CAAA,AA5CD,CAAsC,mBAAQ,GA4C7C;AA5CY,4CAAgB"}
|
|
@@ -16,10 +16,12 @@ export declare enum LOG_LEVELS {
|
|
|
16
16
|
* Configuration options for the logger.
|
|
17
17
|
* @typedef {Object} LoggerConfig
|
|
18
18
|
* @property {boolean | Array<string>} [sensitiveFilteringKeywords] - Specifies whether to filter sensitive keywords in log messages. Can be a boolean value or an array of strings.
|
|
19
|
+
* @property {number} [sensitiveMaxKeys] - Maximum number of keys from an object that sensitive filtering will be applied to. Default value is 10; Increases here should be together with max size at node VM
|
|
19
20
|
* @property {LOG_LEVELS | string} [logLevel] - The log level to use for logging. Can be one of the predefined log levels or a custom string value.
|
|
20
21
|
*/
|
|
21
22
|
export type LoggerConfig = {
|
|
22
23
|
sensitiveFilteringKeywords?: boolean | Array<string>;
|
|
24
|
+
sensitiveMaxKeys?: number;
|
|
23
25
|
logLevel?: LOG_LEVELS | string;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
@@ -349,6 +349,7 @@ var Logger = /** @class */ (function () {
|
|
|
349
349
|
*/
|
|
350
350
|
Logger.prototype.suppressSensitiveInfo = function (value) {
|
|
351
351
|
var _this = this;
|
|
352
|
+
var _a;
|
|
352
353
|
//really false
|
|
353
354
|
if (!this.filterBlacklist || !this.filterBlacklist[0])
|
|
354
355
|
return value;
|
|
@@ -357,11 +358,19 @@ var Logger = /** @class */ (function () {
|
|
|
357
358
|
return value;
|
|
358
359
|
// continue handling for each type
|
|
359
360
|
if (typeof value == 'string') {
|
|
361
|
+
// Try to parse json string
|
|
362
|
+
try {
|
|
363
|
+
return this.suppressSensitiveInfo(JSON.parse(value));
|
|
364
|
+
}
|
|
365
|
+
catch (_b) {
|
|
366
|
+
/* No handling */
|
|
367
|
+
}
|
|
360
368
|
//content based replacement
|
|
361
369
|
this.filterBlacklist.forEach(function (f) {
|
|
370
|
+
var _a;
|
|
362
371
|
var match = value.toLowerCase().includes(f);
|
|
363
372
|
if (match)
|
|
364
|
-
value =
|
|
373
|
+
value = "**SUPPRESSED_SENSITIVE_DATA** (".concat(((_a = String(value)) === null || _a === void 0 ? void 0 : _a.length) || 0, " len)");
|
|
365
374
|
});
|
|
366
375
|
return value;
|
|
367
376
|
}
|
|
@@ -369,14 +378,17 @@ var Logger = /** @class */ (function () {
|
|
|
369
378
|
return value.map(function (v) { return _this.suppressSensitiveInfo(v); });
|
|
370
379
|
}
|
|
371
380
|
else if (typeof value == 'object') {
|
|
372
|
-
//avoid supressing long objects and causing stack overflow
|
|
373
|
-
if (Object.keys(value).length >= 10)
|
|
381
|
+
// avoid supressing long objects and causing stack overflow
|
|
382
|
+
if (Object.keys(value).length >= (((_a = this.config) === null || _a === void 0 ? void 0 : _a.sensitiveMaxKeys) || 10))
|
|
374
383
|
return value;
|
|
375
|
-
//key based replacement
|
|
384
|
+
// key based replacement
|
|
376
385
|
Object.keys(value).forEach(function (elt) {
|
|
377
|
-
var
|
|
378
|
-
|
|
379
|
-
|
|
386
|
+
var _a;
|
|
387
|
+
// do not match sensitive keys with null vals
|
|
388
|
+
var match = value[elt] && _this.filterBlacklist.find(function (f) { return elt.toLowerCase().includes(f); });
|
|
389
|
+
if (match) {
|
|
390
|
+
value[elt] = "**SUPPRESSED_SENSITIVE_DATA** (".concat(((_a = String(value[elt])) === null || _a === void 0 ? void 0 : _a.length) || 0, " len)");
|
|
391
|
+
}
|
|
380
392
|
else
|
|
381
393
|
value[elt] = _this.suppressSensitiveInfo(value[elt]);
|
|
382
394
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/Logger/Logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6BAA8B;AAC9B,+CAAgD;AAChD,wCAAyC;AAEzC,sCAAgC;AAEhC;;;;;;;GAOG;AACH,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6BAAe,CAAA;IACf,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,6BAAe,CAAA;AACjB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AACD;;;;;;GAMG;AACH,IAAM,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAA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B,CAAC,CAAC,CAAC,EAA7B,CAA6B,CAAC,CAAA;QACtD,CAAC;aAAM,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE,CAAC;YACpC,2DAA2D;YAC3D,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,gBAAgB,KAAI,EAAE,CAAC;gBAAE,OAAO,KAAK,CAAA;YACpF,wBAAwB;YACxB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAA,GAAG;;gBAC5B,6CAA6C;gBAC7C,IAAM,KAAK,GACT,KAAK,CAAC,GAAG,CAAC,IAAK,KAAI,CAAC,eAA4B,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,GAAG,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAA7B,CAA6B,CAAC,CAAA;gBAC3F,IAAI,KAAK,EAAE,CAAC;oBACV,KAAK,CAAC,GAAG,CAAC,GAAG,yCAAkC,CAAA,MAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,0CAAE,MAAM,KAAI,CAAC,UAAO,CAAA;gBACvF,CAAC;;oBAAM,KAAK,CAAC,GAAG,CAAC,GAAG,KAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;YAC5D,CAAC,CAAC,CAAA;YACF,OAAO,KAAK,CAAA;QACd,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACH,aAAC;AAAD,CAAC,AA7QD,IA6QC"}
|
|
@@ -99,7 +99,6 @@ var Server = /** @class */ (function () {
|
|
|
99
99
|
this.parsePathParams(request, route.path);
|
|
100
100
|
// Validate path
|
|
101
101
|
if (route.pathSchema) {
|
|
102
|
-
console.log('VVVV', request.getPathParams());
|
|
103
102
|
validationResp = Validator_1.default.validateSchema(request.getPathParams(), route.pathSchema);
|
|
104
103
|
if (validationResp && validationResp instanceof Response_1.default)
|
|
105
104
|
return [2 /*return*/, validationResp];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../../../src/Server/lib/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAA6C;AAG7C,+CAAyC;AACzC,2DAAqD;AACrD,wDAAkD;AAElD,kDAA4C;AAE5C;;GAEG;AACH;IAcE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9C,CAAC;IAED;;;;;OAKG;IACU,sCAAqB,GAAlC,UAAmC,KAA2B,EAAE,OAAgB;;;;;;oBAC9E,mBAAmB;oBACnB,qBAAM,IAAI,qBAAW,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,UAAM,WAAW;;;;;wCACpE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAA;wCAC7B,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;6CACjF,KAAK,EAAL,wBAAK;wCACP,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;wCAC5D,iBAAiB;wCACjB,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;4CAChB,cAAc,GAAG,mBAAS,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,WAAW,CAAC,CAAA;4CACrF,IAAI,cAAc,I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AAE,CAAC,EAAA;;;6BACtD,CAAC,EAAA;;wBAlCF,mBAAmB;wBACnB,SAiCE,CAAA;;;;;KACH;IAED;;;;;OAKG;IACK,gCAAe,GAAvB,UAAwB,GAA2B,EAAE,SAAiB;QACpE,IAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAM,IAAI,GAAG,EAAE,CAAA;QACf,IAAM,MAAM,GAAG,IAAA,6BAAY,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,IAAI,MAAM;YAAE,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClD,CAAC;IACH,aAAC;AAAD,CAAC,AAxFD,IAwFC"}
|
package/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import Utils from './src/API/Utils'
|
|
|
4
4
|
import EventProcessor from './src/BaseEvent/EventProcessor'
|
|
5
5
|
import Process from './src/BaseEvent/Process'
|
|
6
6
|
import Transaction from './src/BaseEvent/Transaction'
|
|
7
|
+
import Redis from './src/Cache/Redis'
|
|
7
8
|
import Configuration from './src/Config/Configuration'
|
|
8
9
|
import Crypto from './src/Crypto/Crypto'
|
|
9
10
|
import JWT from './src/Crypto/JWT'
|
|
@@ -12,19 +13,26 @@ import Mailer from './src/Mailer/Mailer'
|
|
|
12
13
|
import Router, { Route } from './src/Server/Router'
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
16
|
+
* This module exports various classes and utilities for handling transactions, processes, events, routing,
|
|
17
|
+
* mailing, cryptography, JWT, configuration, Redis, responses, utilities, routes, response error types,
|
|
18
|
+
* HTTP methods, and databases.
|
|
19
|
+
* @exports {
|
|
20
|
+
* Transaction,
|
|
21
|
+
* Process,
|
|
22
|
+
* EventProcessor,
|
|
23
|
+
* Router,
|
|
24
|
+
* Mailer,
|
|
25
|
+
* Crypto,
|
|
26
|
+
* JWT,
|
|
27
|
+
* Configuration,
|
|
28
|
+
* Redis,
|
|
29
|
+
* Response,
|
|
30
|
+
* Utils,
|
|
31
|
+
* Route,
|
|
32
|
+
* ResponseErrorType,
|
|
33
|
+
* HttpMethod,
|
|
34
|
+
* Database,
|
|
35
|
+
* }
|
|
28
36
|
*/
|
|
29
37
|
export {
|
|
30
38
|
// Base Events
|
|
@@ -37,6 +45,7 @@ export {
|
|
|
37
45
|
Crypto,
|
|
38
46
|
JWT,
|
|
39
47
|
Configuration,
|
|
48
|
+
Redis,
|
|
40
49
|
// API
|
|
41
50
|
Response,
|
|
42
51
|
// Helpers
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creator.co/wapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"parse-duration": "^1.1.0",
|
|
42
42
|
"path-to-regexp": "^6.2.1",
|
|
43
43
|
"pg": "^8.11.3",
|
|
44
|
+
"redis": "^4.6.13",
|
|
44
45
|
"sha1": "^1.1.1",
|
|
45
46
|
"stack-trace": "0.0.10",
|
|
46
47
|
"zod": "^3.22.4"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RedisClientType, createClient } from 'redis'
|
|
2
|
+
|
|
3
|
+
import { CacheConfig } from './types'
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Redis cache connection class.
|
|
6
|
+
*/
|
|
7
|
+
export default class Redis {
|
|
8
|
+
/**
|
|
9
|
+
* Private static property that holds the connection to a Redis client.
|
|
10
|
+
* @type {RedisClientType}
|
|
11
|
+
*/
|
|
12
|
+
private static _connection: RedisClientType
|
|
13
|
+
/**
|
|
14
|
+
* A private static property that holds a reference to the redis.createClient function.
|
|
15
|
+
* This property is used to create client.
|
|
16
|
+
*/
|
|
17
|
+
private static ClientFactory = createClient
|
|
18
|
+
private static awaitingConnectionQueue: any
|
|
19
|
+
/**
|
|
20
|
+
* Establishes a connection to a Redis cache based on the provided configuration.
|
|
21
|
+
* If a connection is already established, it returns the existing connection.
|
|
22
|
+
* If a connection is pending, it waits for the connection to be established and then returns it.
|
|
23
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to Redis cache.
|
|
24
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client once the connection is established.
|
|
25
|
+
*/
|
|
26
|
+
public static async connection(config: CacheConfig<'redis'>): Promise<RedisClientType> {
|
|
27
|
+
// No connection, but waiting connection queue is valid? wait until other promise
|
|
28
|
+
// fulfill this promise
|
|
29
|
+
if (!Redis._connection && Redis.awaitingConnectionQueue) {
|
|
30
|
+
return new Promise(resolve => Redis.awaitingConnectionQueue.push(resolve))
|
|
31
|
+
} else if (Redis._connection) return Redis._connection //already connected
|
|
32
|
+
// Connect
|
|
33
|
+
Redis.awaitingConnectionQueue = []
|
|
34
|
+
const con = await Redis.redisConnection(config)
|
|
35
|
+
if (Redis.awaitingConnectionQueue) {
|
|
36
|
+
Redis.awaitingConnectionQueue.forEach(resolve => resolve(con))
|
|
37
|
+
}
|
|
38
|
+
Redis.awaitingConnectionQueue = null
|
|
39
|
+
return con
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Establishes a connection to a Redis client based on the provided configuration
|
|
43
|
+
* and holds it for reusability. If connection is detected closed, new connection is
|
|
44
|
+
* initialized and established.
|
|
45
|
+
* @param {CacheConfig<'redis'>} config - The configuration object for connecting to the Redis client.
|
|
46
|
+
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client connection.
|
|
47
|
+
*/
|
|
48
|
+
private static async redisConnection(config: CacheConfig<'redis'>): Promise<RedisClientType> {
|
|
49
|
+
if (Redis._connection && Redis._connection.isOpen) return Redis._connection
|
|
50
|
+
console.debug('Starting remote cache connection')
|
|
51
|
+
const connection = Redis.ClientFactory({
|
|
52
|
+
username: config.username,
|
|
53
|
+
...(config.password ? { password: config.password } : {}),
|
|
54
|
+
disableOfflineQueue: true,
|
|
55
|
+
socket: {
|
|
56
|
+
host: config.hostname,
|
|
57
|
+
...(config.enableTLS ? { tls: true } : {}),
|
|
58
|
+
connectTimeout: 10000,
|
|
59
|
+
},
|
|
60
|
+
})
|
|
61
|
+
await connection.connect()
|
|
62
|
+
Redis._connection = connection as any
|
|
63
|
+
return Redis._connection
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Redis from './Redis'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Defines a type alias for specifying the cache type as 'redis'.
|
|
5
|
+
*/
|
|
6
|
+
export type CacheType = 'redis'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Defines a CacheClass type that has a 'redis' property which is a constructor function
|
|
10
|
+
* that takes in any number of arguments and returns an instance of Redis.
|
|
11
|
+
*/
|
|
12
|
+
export type CacheClass = {
|
|
13
|
+
redis: new (...args: any[]) => Redis
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the base configuration for a cache, including host, username, password, and TLS settings.
|
|
18
|
+
*/
|
|
19
|
+
export type CacheBaseConfig = {
|
|
20
|
+
hostname: string
|
|
21
|
+
username: string
|
|
22
|
+
password?: string
|
|
23
|
+
enableTLS: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Defines a CacheConfig type that extends CacheBaseConfig and includes a specific cache type.
|
|
28
|
+
* @template S - The specific cache type to be included in the CacheConfig.
|
|
29
|
+
* @extends CacheBaseConfig
|
|
30
|
+
* @property {S} type - The specific cache type included in the CacheConfig.
|
|
31
|
+
*/
|
|
32
|
+
export type CacheConfig<S extends CacheType> = CacheBaseConfig & { type: S }
|
|
@@ -14,7 +14,7 @@ export class KnexDatabase extends Database<KnexTransaction> {
|
|
|
14
14
|
* @param {knex.Knex.Config<any>} config - The configuration object for Knex.
|
|
15
15
|
* @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
private static knexProvider: (config: knex.Knex.Config<any>) => knex.Knex<any, unknown[]> = knex
|
|
18
18
|
/**
|
|
19
19
|
* Represents a Knex client for interacting with a database.
|
|
20
20
|
* @type {Knex}
|
|
@@ -9,22 +9,22 @@ import type { DbBaseConfig, DbConfig } from '../../types'
|
|
|
9
9
|
* Represents a database connection using the Kysely library with support for transactions.
|
|
10
10
|
* @template DBSchema - The schema type for the database.
|
|
11
11
|
*/
|
|
12
|
-
export class KyselyDatabase<DBSchema> extends Database<KyselyTransaction<DBSchema>> {
|
|
12
|
+
export class KyselyDatabase<DBSchema = never> extends Database<KyselyTransaction<DBSchema>> {
|
|
13
13
|
/**
|
|
14
14
|
* Represents a PostgreSQL provider for querying data using the PostgresDialect.
|
|
15
15
|
* @type {PostgresDialect}
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
private static kyselyPgProvider = PostgresDialect
|
|
18
18
|
/**
|
|
19
19
|
* A public static property that provides access to the Kysely class.
|
|
20
20
|
* This property can be accessed without creating an instance of the class.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
private static kyselyProvider = Kysely
|
|
23
23
|
/**
|
|
24
24
|
* A static property that represents a connection pool for PostgreSQL database connections.
|
|
25
25
|
* @type {Pool}
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
private static pgProvider = Pool
|
|
28
28
|
/**
|
|
29
29
|
* Represents a PostgreSQL client using the PostgresDialect.
|
|
30
30
|
*/
|
|
@@ -13,7 +13,7 @@ export class PostgresDatabase extends Database<PostgresTransaction> {
|
|
|
13
13
|
* A public static property that represents a connection pool for a PostgreSQL database.
|
|
14
14
|
* This property is used to manage and provide connections to the PostgreSQL database.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
private static pgProvider = Pool
|
|
17
17
|
/**
|
|
18
18
|
* Represents a connection pool to manage multiple client connections to the database.
|
|
19
19
|
*/
|
package/src/Logger/Logger.ts
CHANGED
|
@@ -44,10 +44,12 @@ const blacklist = ['password', 'token', 'accounts'].map(s => s.toLowerCase())
|
|
|
44
44
|
* Configuration options for the logger.
|
|
45
45
|
* @typedef {Object} LoggerConfig
|
|
46
46
|
* @property {boolean | Array<string>} [sensitiveFilteringKeywords] - Specifies whether to filter sensitive keywords in log messages. Can be a boolean value or an array of strings.
|
|
47
|
+
* @property {number} [sensitiveMaxKeys] - Maximum number of keys from an object that sensitive filtering will be applied to. Default value is 10; Increases here should be together with max size at node VM
|
|
47
48
|
* @property {LOG_LEVELS | string} [logLevel] - The log level to use for logging. Can be one of the predefined log levels or a custom string value.
|
|
48
49
|
*/
|
|
49
50
|
export type LoggerConfig = {
|
|
50
51
|
sensitiveFilteringKeywords?: boolean | Array<string>
|
|
52
|
+
sensitiveMaxKeys?: number
|
|
51
53
|
logLevel?: LOG_LEVELS | string
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -293,22 +295,31 @@ export default class Logger {
|
|
|
293
295
|
if (!value) return value
|
|
294
296
|
// continue handling for each type
|
|
295
297
|
if (typeof value == 'string') {
|
|
298
|
+
// Try to parse json string
|
|
299
|
+
try {
|
|
300
|
+
return this.suppressSensitiveInfo(JSON.parse(value))
|
|
301
|
+
} catch {
|
|
302
|
+
/* No handling */
|
|
303
|
+
}
|
|
296
304
|
//content based replacement
|
|
297
305
|
this.filterBlacklist.forEach(f => {
|
|
298
306
|
const match = value.toLowerCase().includes(f)
|
|
299
|
-
if (match) value =
|
|
307
|
+
if (match) value = `**SUPPRESSED_SENSITIVE_DATA** (${String(value)?.length || 0} len)`
|
|
300
308
|
})
|
|
301
309
|
return value
|
|
302
310
|
} else if (Array.isArray(value)) {
|
|
303
311
|
return value.map(v => this.suppressSensitiveInfo(v))
|
|
304
312
|
} else if (typeof value == 'object') {
|
|
305
|
-
//avoid supressing long objects and causing stack overflow
|
|
306
|
-
if (Object.keys(value).length >= 10) return value
|
|
307
|
-
//key based replacement
|
|
313
|
+
// avoid supressing long objects and causing stack overflow
|
|
314
|
+
if (Object.keys(value).length >= (this.config?.sensitiveMaxKeys || 10)) return value
|
|
315
|
+
// key based replacement
|
|
308
316
|
Object.keys(value).forEach(elt => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
// do not match sensitive keys with null vals
|
|
318
|
+
const match =
|
|
319
|
+
value[elt] && (this.filterBlacklist as string[]).find(f => elt.toLowerCase().includes(f))
|
|
320
|
+
if (match) {
|
|
321
|
+
value[elt] = `**SUPPRESSED_SENSITIVE_DATA** (${String(value[elt])?.length || 0} len)`
|
|
322
|
+
} else value[elt] = this.suppressSensitiveInfo(value[elt])
|
|
312
323
|
})
|
|
313
324
|
return value
|
|
314
325
|
}
|
package/src/Server/lib/Server.ts
CHANGED
|
@@ -75,7 +75,6 @@ export default class Server {
|
|
|
75
75
|
this.parsePathParams(request, route.path)
|
|
76
76
|
// Validate path
|
|
77
77
|
if (route.pathSchema) {
|
|
78
|
-
console.log('VVVV', request.getPathParams())
|
|
79
78
|
const validationResp = Validator.validateSchema(request.getPathParams(), route.pathSchema)
|
|
80
79
|
if (validationResp && validationResp instanceof Response) return validationResp
|
|
81
80
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import Redis from '../../src/Cache/Redis'
|
|
2
|
+
|
|
3
|
+
let _connectionId = 1
|
|
4
|
+
async function simpleRedisTest(config: any, concurrent?: boolean) {
|
|
5
|
+
const RedisMock = jest.fn(() => {
|
|
6
|
+
let opened = false
|
|
7
|
+
const connectionId = _connectionId++
|
|
8
|
+
return {
|
|
9
|
+
connectionId,
|
|
10
|
+
isOpen: () => opened,
|
|
11
|
+
close: () => (opened = false),
|
|
12
|
+
connect: jest.fn(() => {
|
|
13
|
+
opened = true
|
|
14
|
+
return {
|
|
15
|
+
mget: jest.fn(() => {
|
|
16
|
+
return true
|
|
17
|
+
}),
|
|
18
|
+
}
|
|
19
|
+
}),
|
|
20
|
+
} as any
|
|
21
|
+
})
|
|
22
|
+
Redis['ClientFactory'] = RedisMock
|
|
23
|
+
// Cleanup previous connection
|
|
24
|
+
if (Redis['_connection']) (await Redis.connection({} as any))?.['close']()
|
|
25
|
+
// Double call is intentional
|
|
26
|
+
let provider, provider2
|
|
27
|
+
if (concurrent) {
|
|
28
|
+
const ps = await Promise.all([Redis.connection(config as any), Redis.connection(config as any)])
|
|
29
|
+
provider = ps[0]
|
|
30
|
+
provider2 = ps[1]
|
|
31
|
+
} else {
|
|
32
|
+
provider = await Redis.connection(config as any)
|
|
33
|
+
provider2 = await Redis.connection(config as any)
|
|
34
|
+
}
|
|
35
|
+
// client checks
|
|
36
|
+
expect(RedisMock).toHaveBeenNthCalledWith(1, {
|
|
37
|
+
username: config.username,
|
|
38
|
+
...(config.password ? { password: config.password } : {}),
|
|
39
|
+
disableOfflineQueue: true,
|
|
40
|
+
socket: {
|
|
41
|
+
host: config.hostname,
|
|
42
|
+
...(config.enableTLS ? { tls: true } : {}),
|
|
43
|
+
connectTimeout: 10000,
|
|
44
|
+
},
|
|
45
|
+
})
|
|
46
|
+
// Does not have double connection
|
|
47
|
+
expect(provider.connectionId).toEqual(provider2.connectionId)
|
|
48
|
+
expect(provider.connect).toHaveBeenCalledTimes(1)
|
|
49
|
+
expect(provider2.connect).toHaveBeenCalledTimes(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
describe('Redis', () => {
|
|
53
|
+
beforeEach(async () => {
|
|
54
|
+
// hack to close singleton connection
|
|
55
|
+
if (Redis['_connection']) (await Redis.connection({} as any))?.['close']()
|
|
56
|
+
})
|
|
57
|
+
test('Simple redis - do not connect twice', async () => {
|
|
58
|
+
Redis['_connection'] = null as any
|
|
59
|
+
await simpleRedisTest({
|
|
60
|
+
hostname: 'redis://localhost',
|
|
61
|
+
username: 'gabe',
|
|
62
|
+
password: 'mypassword',
|
|
63
|
+
enableTLS: true,
|
|
64
|
+
type: 'redis',
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
test('Simple redis (no SSL) - do not connect twice', async () => {
|
|
68
|
+
Redis['_connection'] = null as any
|
|
69
|
+
await simpleRedisTest({
|
|
70
|
+
hostname: 'redis://localhost',
|
|
71
|
+
username: 'gabe',
|
|
72
|
+
password: 'mypassword',
|
|
73
|
+
enableTLS: false,
|
|
74
|
+
type: 'redis',
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
test('Simple redis (passwordless) - do not connect twice', async () => {
|
|
78
|
+
Redis['_connection'] = null as any
|
|
79
|
+
await simpleRedisTest({
|
|
80
|
+
hostname: 'redis://localhost',
|
|
81
|
+
username: 'gabe',
|
|
82
|
+
enableTLS: false,
|
|
83
|
+
type: 'redis',
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
test('Concurrent redis - do not connect twice', async () => {
|
|
87
|
+
Redis['_connection'] = null as any
|
|
88
|
+
await simpleRedisTest(
|
|
89
|
+
{
|
|
90
|
+
hostname: 'redis://localhost',
|
|
91
|
+
username: 'gabe',
|
|
92
|
+
enableTLS: false,
|
|
93
|
+
type: 'redis',
|
|
94
|
+
},
|
|
95
|
+
true
|
|
96
|
+
)
|
|
97
|
+
})
|
|
98
|
+
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { expect as c_expect } from 'chai'
|
|
2
1
|
import { PostgresDialect } from 'kysely'
|
|
3
2
|
import { PoolClient } from 'pg'
|
|
4
3
|
|
|
@@ -78,8 +77,9 @@ describe('KyselyDatabase', () => {
|
|
|
78
77
|
const underTest = new KyselyDatabase(config)
|
|
79
78
|
expect(mockPgClient).toHaveBeenNthCalledWith(1, expectedImplConfig)
|
|
80
79
|
expect(mockDialect).toHaveBeenCalledTimes(1)
|
|
81
|
-
expect(mockClient).
|
|
82
|
-
|
|
80
|
+
expect(mockClient).toHaveBeenCalledTimes(1)
|
|
81
|
+
expect(mockClient.mock.calls[0][0].dialect).toEqual(underTest['pgClient'])
|
|
82
|
+
expect(mockClient.mock.calls[0][0].plugins).toBeInstanceOf(Array)
|
|
83
83
|
const trans = await underTest.transaction()
|
|
84
84
|
|
|
85
85
|
expect(mockTrans.execute).toHaveBeenCalledTimes(1)
|
|
@@ -94,8 +94,11 @@ describe('KyselyDatabase', () => {
|
|
|
94
94
|
const underTest = new KyselyDatabase(config2)
|
|
95
95
|
expect(mockPgClient).toHaveBeenNthCalledWith(2, expectedImplConfig)
|
|
96
96
|
expect(mockDialect).toHaveBeenCalledTimes(2)
|
|
97
|
-
expect(mockClient).
|
|
98
|
-
expect(mockClient).
|
|
97
|
+
expect(mockClient).toHaveBeenCalledTimes(2)
|
|
98
|
+
expect(mockClient.mock.calls[0][0].dialect).toEqual(underTest['pgClient'])
|
|
99
|
+
expect(mockClient.mock.calls[0][0].plugins).toBeInstanceOf(Array)
|
|
100
|
+
expect(mockClient.mock.calls[1][0].dialect).toEqual(underTest['pgReadClient'])
|
|
101
|
+
expect(mockClient.mock.calls[1][0].plugins).toBeInstanceOf(Array)
|
|
99
102
|
|
|
100
103
|
const trans = await underTest.transaction()
|
|
101
104
|
|
|
@@ -23,6 +23,16 @@ function fixLogTypePrefix(logType: string) {
|
|
|
23
23
|
return logType
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function randomDeepObject(count, endKey) {
|
|
27
|
+
if (count <= 1) return { [endKey]: 'value' }
|
|
28
|
+
const object = {}
|
|
29
|
+
for (let i = 0; i < count; i++) {
|
|
30
|
+
const key = (+new Date() * Math.random()).toString(36).substring(0, 6)
|
|
31
|
+
object[key] = randomDeepObject(Math.floor(Math.random() * (count / 2)), endKey)
|
|
32
|
+
}
|
|
33
|
+
return object
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
function testLogs(isContainer: boolean, provider?: Logger) {
|
|
27
37
|
const type = isContainer ? 'container' : 'serverless'
|
|
28
38
|
const loggerType = !provider ? 'Console' : 'Logger'
|
|
@@ -37,7 +47,7 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
37
47
|
)
|
|
38
48
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
39
49
|
1,
|
|
40
|
-
expect.stringContaining('] **SUPPRESSED_SENSITIVE_DATA**')
|
|
50
|
+
expect.stringContaining('] **SUPPRESSED_SENSITIVE_DATA** (18 len)')
|
|
41
51
|
)
|
|
42
52
|
})
|
|
43
53
|
|
|
@@ -51,13 +61,43 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
51
61
|
)
|
|
52
62
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
53
63
|
1,
|
|
54
|
-
expect.stringContaining('] TEST {\n "password": "**SUPPRESSED_SENSITIVE_DATA**"\n}')
|
|
64
|
+
expect.stringContaining('] TEST {\n "password": "**SUPPRESSED_SENSITIVE_DATA** (3 len)"\n}')
|
|
55
65
|
)
|
|
56
66
|
// test if object is not mutate
|
|
57
67
|
c_expect(object.password).to.be.equals('123')
|
|
58
68
|
})
|
|
59
69
|
|
|
70
|
+
test(`${type} - ${loggerType} Log - Suppress sensitive info (long-object)`, async () => {
|
|
71
|
+
setContainerFlag(isContainer)
|
|
72
|
+
const object = randomDeepObject(99, 'password')
|
|
73
|
+
localProvider.log('TEST', object)
|
|
74
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
75
|
+
1,
|
|
76
|
+
expect.stringContaining((isContainer ? `${transactionID} ` : '') + '[INFO] [Logger.test.ts:')
|
|
77
|
+
)
|
|
78
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(1, expect.stringContaining('] TEST'))
|
|
79
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
80
|
+
1,
|
|
81
|
+
expect.stringContaining('"password": "**SUPPRESSED_SENSITIVE_DATA** (5 len)"')
|
|
82
|
+
)
|
|
83
|
+
})
|
|
84
|
+
|
|
60
85
|
test(`${type} - ${loggerType} Log - Suppress sensitive info (object with sensitive string)`, async () => {
|
|
86
|
+
setContainerFlag(isContainer)
|
|
87
|
+
localProvider.log({ object: JSON.stringify({ password: '123' }) })
|
|
88
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
89
|
+
1,
|
|
90
|
+
expect.stringContaining((isContainer ? `${transactionID} ` : '') + '[INFO] [Logger.test.ts:')
|
|
91
|
+
)
|
|
92
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
93
|
+
1,
|
|
94
|
+
expect.stringContaining(
|
|
95
|
+
'] {\n "object": {\n "password": "**SUPPRESSED_SENSITIVE_DATA** (3 len)"\n }\n}'
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
test(`${type} - ${loggerType} Log - Suppress sensitive info (object with sensitive number)`, async () => {
|
|
61
101
|
setContainerFlag(isContainer)
|
|
62
102
|
localProvider.log({ object: JSON.stringify({ password: 123 }) })
|
|
63
103
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
@@ -66,7 +106,22 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
66
106
|
)
|
|
67
107
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
68
108
|
1,
|
|
69
|
-
expect.stringContaining(
|
|
109
|
+
expect.stringContaining(
|
|
110
|
+
'] {\n "object": {\n "password": "**SUPPRESSED_SENSITIVE_DATA** (3 len)"\n }\n}'
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
test(`${type} - ${loggerType} Log - Suppress sensitive info (null key)`, async () => {
|
|
116
|
+
setContainerFlag(isContainer)
|
|
117
|
+
localProvider.log({ object: JSON.stringify({ password: null }) })
|
|
118
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
119
|
+
1,
|
|
120
|
+
expect.stringContaining((isContainer ? `${transactionID} ` : '') + '[INFO] [Logger.test.ts:')
|
|
121
|
+
)
|
|
122
|
+
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
123
|
+
1,
|
|
124
|
+
expect.stringContaining('] {\n "object": {\n "password": null\n }\n}')
|
|
70
125
|
)
|
|
71
126
|
})
|
|
72
127
|
|
|
@@ -82,7 +137,7 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
82
137
|
|
|
83
138
|
test(`${type} - ${loggerType} Log - Suppress sensitive info (array)`, async () => {
|
|
84
139
|
setContainerFlag(isContainer)
|
|
85
|
-
localProvider.log('TEST2', [{ password: '
|
|
140
|
+
localProvider.log('TEST2', [{ password: '1234' }])
|
|
86
141
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
87
142
|
1,
|
|
88
143
|
expect.stringContaining((isContainer ? `${transactionID} ` : '') + '[INFO] [Logger.test.ts:')
|
|
@@ -90,7 +145,7 @@ function testLogs(isContainer: boolean, provider?: Logger) {
|
|
|
90
145
|
expect(consoleProxy.log).toHaveBeenNthCalledWith(
|
|
91
146
|
1,
|
|
92
147
|
expect.stringContaining(
|
|
93
|
-
'] TEST2 [\n {\n "password": "**SUPPRESSED_SENSITIVE_DATA**"\n }\n]'
|
|
148
|
+
'] TEST2 [\n {\n "password": "**SUPPRESSED_SENSITIVE_DATA** (4 len)"\n }\n]'
|
|
94
149
|
)
|
|
95
150
|
)
|
|
96
151
|
})
|
|
@@ -124,6 +179,7 @@ describe('Logger', () => {
|
|
|
124
179
|
{
|
|
125
180
|
logLevel: 'DEBUG',
|
|
126
181
|
sensitiveFilteringKeywords: true,
|
|
182
|
+
sensitiveMaxKeys: 100,
|
|
127
183
|
},
|
|
128
184
|
transactionID
|
|
129
185
|
)
|