@creator.co/wapi 1.5.2 → 1.5.3
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 +3 -2
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/API/Request.js +1 -1
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/Cache/Redis.d.ts +1 -13
- package/dist/src/Cache/Redis.js +12 -42
- package/dist/src/Cache/Redis.js.map +1 -1
- package/dist/src/Globals.js +1 -1
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.js +1 -1
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Server/Router.js +1 -1
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.js +1 -1
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.js +1 -1
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Util/AsyncSingleton.d.ts +31 -0
- package/dist/src/Util/AsyncSingleton.js +207 -0
- package/dist/src/Util/AsyncSingleton.js.map +1 -0
- package/dist/src/Util/Utils.js.map +1 -0
- package/index.ts +3 -1
- package/package.json +1 -1
- package/src/API/Request.ts +1 -1
- package/src/Cache/Redis.ts +12 -30
- package/src/Globals.ts +1 -1
- package/src/Logger/Logger.ts +1 -1
- package/src/Server/Router.ts +1 -1
- package/src/Server/lib/container/GenericHandler.ts +1 -1
- package/src/Server/lib/container/Proxy.ts +1 -1
- package/src/Util/AsyncSingleton.ts +86 -0
- package/tests/API/Utils.test.ts +1 -1
- package/tests/Cache/Redis.test.ts +7 -17
- package/dist/src/API/Utils.js.map +0 -1
- /package/dist/src/{API → Util}/Utils.d.ts +0 -0
- /package/dist/src/{API → Util}/Utils.js +0 -0
- /package/src/{API → Util}/Utils.ts +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HttpMethod } from './src/API/Request';
|
|
2
2
|
import Response, { ResponseErrorType } from './src/API/Response';
|
|
3
|
-
import Utils from './src/API/Utils';
|
|
4
3
|
import EventProcessor from './src/BaseEvent/EventProcessor';
|
|
5
4
|
import Process from './src/BaseEvent/Process';
|
|
6
5
|
import Transaction from './src/BaseEvent/Transaction';
|
|
@@ -11,6 +10,8 @@ import JWT from './src/Crypto/JWT';
|
|
|
11
10
|
import * as Database from './src/Database';
|
|
12
11
|
import Mailer from './src/Mailer/Mailer';
|
|
13
12
|
import Router, { Route } from './src/Server/Router';
|
|
13
|
+
import AsyncSingleton from './src/Util/AsyncSingleton';
|
|
14
|
+
import Utils from './src/Util/Utils';
|
|
14
15
|
/**
|
|
15
16
|
* This module exports various classes and utilities for handling transactions, processes, events, routing,
|
|
16
17
|
* mailing, cryptography, JWT, configuration, Redis, responses, utilities, routes, response error types,
|
|
@@ -33,4 +34,4 @@ import Router, { Route } from './src/Server/Router';
|
|
|
33
34
|
* Database,
|
|
34
35
|
* }
|
|
35
36
|
*/
|
|
36
|
-
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Redis, Response, Utils, Route, ResponseErrorType, HttpMethod, Database, };
|
|
37
|
+
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Redis, Response, Utils, AsyncSingleton, Route, ResponseErrorType, HttpMethod, Database, };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.Database = exports.HttpMethod = exports.AsyncSingleton = 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");
|
|
7
7
|
exports.Response = Response_1.default;
|
|
8
|
-
var Utils_1 = require("./src/API/Utils");
|
|
9
|
-
exports.Utils = Utils_1.default;
|
|
10
8
|
var EventProcessor_1 = require("./src/BaseEvent/EventProcessor");
|
|
11
9
|
exports.EventProcessor = EventProcessor_1.default;
|
|
12
10
|
var Process_1 = require("./src/BaseEvent/Process");
|
|
@@ -27,4 +25,8 @@ var Mailer_1 = require("./src/Mailer/Mailer");
|
|
|
27
25
|
exports.Mailer = Mailer_1.default;
|
|
28
26
|
var Router_1 = require("./src/Server/Router");
|
|
29
27
|
exports.Router = Router_1.default;
|
|
28
|
+
var AsyncSingleton_1 = require("./src/Util/AsyncSingleton");
|
|
29
|
+
exports.AsyncSingleton = AsyncSingleton_1.default;
|
|
30
|
+
var Utils_1 = require("./src/Util/Utils");
|
|
31
|
+
exports.Utils = Utils_1.default;
|
|
30
32
|
//# sourceMappingURL=index.js.map
|
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;AAyD5C,2FAzDO,oBAAU,OAyDP;AAxDZ,+CAAgE;AAiD9D,mBAjDK,kBAAQ,CAiDL;AAhDV,iEAA2D;AAuCzD,yBAvCK,wBAAc,CAuCL;AAtChB,mDAA6C;AAqC3C,kBArCK,iBAAO,CAqCL;AApCT,2DAAqD;AAmCnD,sBAnCK,qBAAW,CAmCL;AAlCb,2CAAqC;AA2CnC,gBA3CK,eAAK,CA2CL;AA1CP,4DAAsD;AAyCpD,wBAzCK,uBAAa,CAyCL;AAxCf,8CAAwC;AAsCtC,iBAtCK,gBAAM,CAsCL;AArCR,wCAAkC;AAsChC,cAtCK,aAAG,CAsCL;AArCL,yCAA0C;AAiDxC,4BAAQ;AAhDV,8CAAwC;AAkCtC,iBAlCK,gBAAM,CAkCL;AAjCR,8CAAmD;AA+BjD,iBA/BK,gBAAM,CA+BL;AA9BR,4DAAsD;AAyCpD,yBAzCK,wBAAc,CAyCL;AAxChB,0CAAoC;AAuClC,gBAvCK,eAAK,CAuCL"}
|
package/dist/package.json
CHANGED
package/dist/src/API/Request.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpMethod = void 0;
|
|
4
|
-
var Utils_1 = require("
|
|
4
|
+
var Utils_1 = require("../Util/Utils");
|
|
5
5
|
/**
|
|
6
6
|
* Represents a request object with generic types for input, query parameters, and path parameters.
|
|
7
7
|
* @class Request
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;;AAGA,uCAAiC;AAEjC;;;;;;GAMG;AACH;IAWE;;;;;;OAMG;IACH,iBAAY,YAA6B,EAAE,OAAgB,EAAE,MAAc;QACzE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,YAAY,CAAC,CAAA;QAC3C,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAA;IAC3C,CAAC;IAED;;;;OAIG;IACI,oCAAkB,GAAzB,UAA0B,SAAgC;QACxD,IAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC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4,12 @@ import { CacheConfig } from './types';
|
|
|
4
4
|
* Represents a Redis cache connection class.
|
|
5
5
|
*/
|
|
6
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;
|
|
7
|
+
private static singleton;
|
|
12
8
|
/**
|
|
13
9
|
* A private static property that holds a reference to the redis.createClient function.
|
|
14
10
|
* This property is used to create client.
|
|
15
11
|
*/
|
|
16
12
|
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
13
|
static connection(config: CacheConfig<'redis'>): Promise<RedisClientType>;
|
|
26
14
|
/**
|
|
27
15
|
* Establishes a connection to a Redis client based on the provided configuration
|
package/dist/src/Cache/Redis.js
CHANGED
|
@@ -48,47 +48,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
var redis_1 = require("redis");
|
|
51
|
+
var AsyncSingleton_1 = require("../Util/AsyncSingleton");
|
|
51
52
|
/**
|
|
52
53
|
* Represents a Redis cache connection class.
|
|
53
54
|
*/
|
|
54
55
|
var Redis = /** @class */ (function () {
|
|
55
56
|
function Redis() {
|
|
56
57
|
}
|
|
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
58
|
Redis.connection = function (config) {
|
|
65
|
-
return
|
|
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
|
-
});
|
|
59
|
+
return _a.singleton.instance(config);
|
|
92
60
|
};
|
|
93
61
|
/**
|
|
94
62
|
* Establishes a connection to a Redis client based on the provided configuration
|
|
@@ -100,22 +68,24 @@ var Redis = /** @class */ (function () {
|
|
|
100
68
|
Redis.redisConnection = function (config) {
|
|
101
69
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
70
|
var connection;
|
|
103
|
-
return __generator(this, function (
|
|
104
|
-
switch (
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
105
73
|
case 0:
|
|
106
|
-
if (Redis._connection && Redis._connection.isOpen)
|
|
107
|
-
return [2 /*return*/, Redis._connection];
|
|
108
74
|
console.debug('Starting remote cache connection');
|
|
109
|
-
connection =
|
|
75
|
+
connection = _a.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
76
|
return [4 /*yield*/, connection.connect()];
|
|
111
77
|
case 1:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return [2 /*return*/, Redis._connection];
|
|
78
|
+
_b.sent();
|
|
79
|
+
return [2 /*return*/, connection];
|
|
115
80
|
}
|
|
116
81
|
});
|
|
117
82
|
});
|
|
118
83
|
};
|
|
84
|
+
var _a;
|
|
85
|
+
_a = Redis;
|
|
86
|
+
Redis.singleton = new AsyncSingleton_1.default(_a.redisConnection, function (c) { return __awaiter(void 0, void 0, void 0, function () { return __generator(_a, function (_b) {
|
|
87
|
+
return [2 /*return*/, c.isOpen];
|
|
88
|
+
}); }); });
|
|
119
89
|
/**
|
|
120
90
|
* A private static property that holds a reference to the redis.createClient function.
|
|
121
91
|
* This property is used to create client.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Redis.js","sourceRoot":"","sources":["../../../src/Cache/Redis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAqD;AAGrD;;GAEG;AACH;IAAA;
|
|
1
|
+
{"version":3,"file":"Redis.js","sourceRoot":"","sources":["../../../src/Cache/Redis.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAqD;AAGrD,yDAAmD;AACnD;;GAEG;AACH;IAAA;IAuCA,CAAC;IA3Be,gBAAU,GAAxB,UAAyB,MAA4B;QACnD,OAAO,EAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IAED;;;;;;OAMG;IACkB,qBAAe,GAApC,UAAqC,MAA4B;;;;;;wBAC/D,OAAO,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAA;wBAC3C,UAAU,GAAG,EAAK,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;wBAE1B,sBAAO,UAAiB,EAAA;;;;KACzB;;;IArCc,eAAS,GAAG,IAAI,wBAAc,CAC3C,EAAK,CAAC,eAAe,EACrB,UAAM,CAAC;QAAI,sBAAA,CAAC,CAAC,MAAM,EAAA;aAAA,CACpB,AAHuB,CAGvB;IAED;;;OAGG;IACY,mBAAa,GAAG,oBAAY,AAAf,CAAe;IA6B7C,YAAC;CAAA,AAvCD,IAuCC;kBAvCoB,KAAK"}
|
package/dist/src/Globals.js
CHANGED
package/dist/src/Globals.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Globals.js","sourceRoot":"","sources":["../../src/Globals.ts"],"names":[],"mappings":";;AAAA,+BAAgC;AAEhC,
|
|
1
|
+
{"version":3,"file":"Globals.js","sourceRoot":"","sources":["../../src/Globals.ts"],"names":[],"mappings":";;AAAA,+BAAgC;AAEhC,sCAAgC;AAEhC,0CAA0C;AAC1C,M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|
@@ -15,7 +15,7 @@ exports.LOG_LEVELS = void 0;
|
|
|
15
15
|
var abind = require("abind");
|
|
16
16
|
var stringify = require("json-stringify-safe");
|
|
17
17
|
var stackTrace = require("stack-trace");
|
|
18
|
-
var Utils_1 = require("../
|
|
18
|
+
var Utils_1 = require("../Util/Utils");
|
|
19
19
|
/**
|
|
20
20
|
* Enumeration of log levels.
|
|
21
21
|
* @enum {string}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/Logger/Logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6BAA8B;AAC9B,+CAAgD;AAChD,wCAAyC;AAEzC,
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../../src/Logger/Logger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6BAA8B;AAC9B,+CAAgD;AAChD,wCAAyC;AAEzC,uCAAiC;AAEjC;;;;;;;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,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;AAC7E;;;GAGG;AACH,IAAM,oBAAoB,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AAEhE;;;;;GAKG;AACH,IAAM,SAAS,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,EAAE,EAAf,CAAe,CAAC,CAAA;AAe7E;;GAEG;AACH;IA4BE;;;;;OAKG;IACH,gBAAY,MAAgC,EAAE,aAAq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
|
|
4
4
|
var Server_1 = require("./lib/Server");
|
|
5
|
-
var Utils_1 = require("../
|
|
5
|
+
var Utils_1 = require("../Util/Utils");
|
|
6
6
|
/**
|
|
7
7
|
* Represents a router that handles routing logic for a web application.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAQjC,uCAAiC;AA0HjC;;GAEG;AACH;IAUE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,yBAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC;IAED;;;OAGG;IACK,4BAAW,GAAnB;QACE,OAAO,eAAK,CAAC,qBAAqB,EAAE,CAAA;IACtC,CAAC;IACH,aAAC;AAAD,CAAC,AAnCD,IAmCC"}
|
|
@@ -59,8 +59,8 @@ var __values = (this && this.__values) || function(o) {
|
|
|
59
59
|
};
|
|
60
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
61
|
var GenericHandlerEvent_1 = require("./GenericHandlerEvent");
|
|
62
|
-
var Utils_1 = require("../../../API/Utils");
|
|
63
62
|
var Globals_1 = require("../../../Globals");
|
|
63
|
+
var Utils_1 = require("../../../Util/Utils");
|
|
64
64
|
/**
|
|
65
65
|
* Creates an async function that handles serverless events and sends a response.
|
|
66
66
|
* @param {Server['handleServerlessEvent']} serverlessHandler - The serverless handler function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericHandler.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/GenericHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAAwF;AACxF,4CAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"GenericHandler.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/GenericHandler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6DAAwF;AACxF,4CAAsC;AACtC,6CAAuC;AAGvC;;;;GAIG;AACH,mBAAe,UAAC,iBAAkD;IAChE;;;;;OAKG;IACH,OAAO,UAAO,OAAgB,EAAE,GAAa;;;;;oBACrC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;;;;oBAGpB,UAAQ,IAAI,6BAAmB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAA;oBAE1C,qBAAM,OAAK,CAAC,MAAM,EAAE;wBAC3C,UAAU;sBADiC;;oBAArC,cAAc,GAAG,SAAoB;oBAC3C,UAAU;oBACV,yBAAyB,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;;;;oBAE9C,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAC,CAAC,CAAA;oBACzD,OAAO,CAAC,KAAK,CAAC,GAAC,CAAC,KAAK,CAAC,CAAA;oBACtB,GAAG,CAAC,MAAM,CAAC,iBAAO,CAAC,yBAAyB,CAAC,CAAC,IAAI,uBAC7C,GAAC,KACJ,GAAG,EAAE,iBAAO,CAAC,kBAAkB,EAC/B,OAAO,EAAE,iBAAO,CAAC,mBAAmB,IACpC,CAAA;;;oBAEJ,OAAO,CAAC,KAAK,CAAC,iCAA0B,IAAI,CAAC,GAAG,EAAE,GAA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,CAAC,CAAA;QACrC,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAK,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QACpF,CAAC;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -42,8 +42,8 @@ var express = require("express");
|
|
|
42
42
|
var GenericHandler_1 = require("./GenericHandler");
|
|
43
43
|
var HealthHandler_1 = require("./HealthHandler");
|
|
44
44
|
var package_json_1 = require("../../../../package.json");
|
|
45
|
-
var Utils_1 = require("../../../API/Utils");
|
|
46
45
|
var Globals_1 = require("../../../Globals");
|
|
46
|
+
var Utils_1 = require("../../../Util/Utils");
|
|
47
47
|
/**
|
|
48
48
|
* Represents a Proxy class that handles routing and server functionality.
|
|
49
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Proxy.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/Proxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyD;AAEzD,2BAA4B;AAC5B,iCAAkC;AAGlC,mDAA6C;AAC7C,iDAA2C;AAC3C,yDAAgE;AAChE,4CAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"Proxy.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/Proxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAyD;AAEzD,2BAA4B;AAC5B,iCAAkC;AAGlC,mDAA6C;AAC7C,iDAA2C;AAC3C,yDAAgE;AAChE,4CAAsC;AACtC,6CAAuC;AAGvC;;GAEG;AACH;IA4BE;;;;;OAKG;IACH,eAAY,MAAoB,EAAE,iBAAkD;QAClF,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAA;QACrB,IAAI,CAAC,MAAM,GAAG,MA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1B,OAAO,CAAC,IAAI,CAAC,CAAA;wBACf,CAAC,CAAC,CAAA;oBACJ,CAAC,CAAC,EAAA;;;KACH;IAED;;;OAGG;IACK,6BAAa,GAArB;QACE,+DAA+D;QAC/D,mDAAmD;QACnD,OAAO,CAAC,GAAG,CACT,qCACE,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,iBAAO,CAAC,qCAAqC,CAC7E,CACH,CAAA;QACD,IAAI,CAAC,GAAG;aACL,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,IAAI,iBAAO,CAAC,qCAAqC,CAAC;aACpF,GAAG,CAAC,uBAAa,CAAC,CAAA;QACrB,yFAAyF;QACzF,sFAAsF;QACtF,sEAAsE;QACtE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAO,CAAC,wBAAwB,CAAC,CAAC,GAAG,CAAC,IAAA,wBAAc,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAC9F,CAAC;IACH,YAAC;AAAD,CAAC,AAlJD,IAkJC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a class that can be used to create a singleton instance of a class that is created asynchronously.
|
|
3
|
+
*/
|
|
4
|
+
export default class AsyncSingleton<T, R> {
|
|
5
|
+
private readonly factory;
|
|
6
|
+
private readonly checker;
|
|
7
|
+
private queue;
|
|
8
|
+
private instantiating;
|
|
9
|
+
private value?;
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new instance of the AsyncSingleton class.
|
|
12
|
+
* @param factory The factory function that creates the instance.
|
|
13
|
+
* @param checker The function that checks if the instance is valid.
|
|
14
|
+
*/
|
|
15
|
+
constructor(factory: (r: R) => Promise<T>, checker?: (value: T) => Promise<boolean>);
|
|
16
|
+
/**
|
|
17
|
+
* Gets the instance of the class.
|
|
18
|
+
* @param r The configuration object for creating the instance.
|
|
19
|
+
*/
|
|
20
|
+
instance(r: R): Promise<T>;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the current value, may be undefined or invalid.
|
|
23
|
+
*/
|
|
24
|
+
getValue(): T | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Clears the current value and rejects all pending promises.
|
|
27
|
+
*/
|
|
28
|
+
clear(): void;
|
|
29
|
+
private initHere;
|
|
30
|
+
private awaitOtherInit;
|
|
31
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
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
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
/**
|
|
67
|
+
* Represents a class that can be used to create a singleton instance of a class that is created asynchronously.
|
|
68
|
+
*/
|
|
69
|
+
var AsyncSingleton = /** @class */ (function () {
|
|
70
|
+
/**
|
|
71
|
+
* Creates a new instance of the AsyncSingleton class.
|
|
72
|
+
* @param factory The factory function that creates the instance.
|
|
73
|
+
* @param checker The function that checks if the instance is valid.
|
|
74
|
+
*/
|
|
75
|
+
function AsyncSingleton(factory, checker) {
|
|
76
|
+
if (checker === void 0) { checker = function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
77
|
+
return [2 /*return*/, true];
|
|
78
|
+
}); }); }; }
|
|
79
|
+
var _this = this;
|
|
80
|
+
this.queue = [];
|
|
81
|
+
this.instantiating = false;
|
|
82
|
+
this.factory = factory;
|
|
83
|
+
this.checker = checker;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets the instance of the class.
|
|
87
|
+
* @param r The configuration object for creating the instance.
|
|
88
|
+
*/
|
|
89
|
+
AsyncSingleton.prototype.instance = function (r) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var _a;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
switch (_b.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
_a = this.value;
|
|
96
|
+
if (!_a) return [3 /*break*/, 2];
|
|
97
|
+
return [4 /*yield*/, this.checker(this.value)];
|
|
98
|
+
case 1:
|
|
99
|
+
_a = (_b.sent());
|
|
100
|
+
_b.label = 2;
|
|
101
|
+
case 2:
|
|
102
|
+
if (_a)
|
|
103
|
+
return [2 /*return*/, this.value];
|
|
104
|
+
if (!this.instantiating) return [3 /*break*/, 4];
|
|
105
|
+
return [4 /*yield*/, this.awaitOtherInit()];
|
|
106
|
+
case 3: return [2 /*return*/, _b.sent()];
|
|
107
|
+
case 4: return [4 /*yield*/, this.initHere(r)];
|
|
108
|
+
case 5: return [2 /*return*/, _b.sent()];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Gets the current value, may be undefined or invalid.
|
|
115
|
+
*/
|
|
116
|
+
AsyncSingleton.prototype.getValue = function () {
|
|
117
|
+
return this.value;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Clears the current value and rejects all pending promises.
|
|
121
|
+
*/
|
|
122
|
+
AsyncSingleton.prototype.clear = function () {
|
|
123
|
+
var e_1, _a;
|
|
124
|
+
this.value = undefined;
|
|
125
|
+
try {
|
|
126
|
+
for (var _b = __values(this.queue), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
127
|
+
var _d = __read(_c.value, 2), rej = _d[1];
|
|
128
|
+
rej();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
135
|
+
}
|
|
136
|
+
finally { if (e_1) throw e_1.error; }
|
|
137
|
+
}
|
|
138
|
+
this.queue = [];
|
|
139
|
+
};
|
|
140
|
+
AsyncSingleton.prototype.initHere = function (r) {
|
|
141
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
142
|
+
var _a, _b, _c, _d, res, _e, _f, _g, rej;
|
|
143
|
+
var e_2, _h, e_3, _j;
|
|
144
|
+
return __generator(this, function (_k) {
|
|
145
|
+
switch (_k.label) {
|
|
146
|
+
case 0:
|
|
147
|
+
_k.trys.push([0, , 2, 3]);
|
|
148
|
+
this.instantiating = true;
|
|
149
|
+
_a = this;
|
|
150
|
+
return [4 /*yield*/, this.factory(r)];
|
|
151
|
+
case 1:
|
|
152
|
+
_a.value = _k.sent();
|
|
153
|
+
try {
|
|
154
|
+
for (_b = __values(this.queue), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
155
|
+
_d = __read(_c.value, 1), res = _d[0];
|
|
156
|
+
res();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (_c && !_c.done && (_h = _b.return)) _h.call(_b);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_2) throw e_2.error; }
|
|
165
|
+
}
|
|
166
|
+
this.queue = [];
|
|
167
|
+
return [2 /*return*/, this.value];
|
|
168
|
+
case 2:
|
|
169
|
+
try {
|
|
170
|
+
for (_e = __values(this.queue), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
171
|
+
_g = __read(_f.value, 2), rej = _g[1];
|
|
172
|
+
rej();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
176
|
+
finally {
|
|
177
|
+
try {
|
|
178
|
+
if (_f && !_f.done && (_j = _e.return)) _j.call(_e);
|
|
179
|
+
}
|
|
180
|
+
finally { if (e_3) throw e_3.error; }
|
|
181
|
+
}
|
|
182
|
+
this.instantiating = false;
|
|
183
|
+
return [7 /*endfinally*/];
|
|
184
|
+
case 3: return [2 /*return*/];
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
AsyncSingleton.prototype.awaitOtherInit = function () {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var _this = this;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0: return [4 /*yield*/, new Promise(function (res, rej) {
|
|
195
|
+
_this.queue.push([res, rej]);
|
|
196
|
+
})];
|
|
197
|
+
case 1:
|
|
198
|
+
_a.sent();
|
|
199
|
+
return [2 /*return*/, this.value];
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
return AsyncSingleton;
|
|
205
|
+
}());
|
|
206
|
+
exports.default = AsyncSingleton;
|
|
207
|
+
//# sourceMappingURL=AsyncSingleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsyncSingleton.js","sourceRoot":"","sources":["../../../src/Util/AsyncSingleton.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;GAEG;AACH;IASE;;;;OAIG;IACH,wBACE,OAA6B,EAC7B,OAA0D;QAA1D,wBAAA,EAAA;YAAsD,sBAAA,IAAI,EAAA;iBAAA;QAF5D,iBAMC;QAhBO,UAAK,GAAoB,EAAE,CAAA;QAC3B,kBAAa,GAAY,KAAK,CAAA;QAapC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED;;;OAGG;IACU,iCAAQ,GAArB,UAAsB,CAAI;;;;;;wBACpB,KAAA,IAAI,CAAC,KAAK,CAAA;iCAAV,wBAAU;wBAAK,qBAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAA;;wBAA/B,KAAA,CAAC,SAA8B,CAAC,CAAA;;;wBAAlD;4BAAoD,sBAAO,IAAI,CAAC,KAAK,EAAA;6BAEjE,IAAI,CAAC,aAAa,EAAlB,wBAAkB;wBACb,qBAAM,IAAI,CAAC,cAAc,EAAE,EAAA;4BAAlC,sBAAO,SAA2B,EAAA;4BAG7B,qBAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAA;4BAA7B,sBAAO,SAAsB,EAAA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,MAAc;QACxC,IAAI,SAAS,GAAG,GAAG,CAAA;QACnB,IAAI,CAAC;YACH,SAAS,GAAG,QAAQ,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;QACnC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAA;QACnD,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACpD,CAAC;IAED;;;;;OAKG;IACW,iCAA2B,GAAzC,UAA0C,GAAQ,EAAE,GAAW;QAC7D,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAA;QACrB,IAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,EAArC,CAAqC,CAAC,CAAA;QACxF,IAAI,cAAc,IAAI,cAAc,IAAI,EAAE;YAAE,OAAO,GAAG,CAAC,cAAc,CAAC,CAAA;QACtE,OAAO,IAAI,CAAA;IACb,CAAC;IACH,YAAC;AAAD,CAAC,AAxED,IAwEC"}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { HttpMethod } from './src/API/Request'
|
|
2
2
|
import Response, { ResponseErrorType } from './src/API/Response'
|
|
3
|
-
import Utils from './src/API/Utils'
|
|
4
3
|
import EventProcessor from './src/BaseEvent/EventProcessor'
|
|
5
4
|
import Process from './src/BaseEvent/Process'
|
|
6
5
|
import Transaction from './src/BaseEvent/Transaction'
|
|
@@ -11,6 +10,8 @@ import JWT from './src/Crypto/JWT'
|
|
|
11
10
|
import * as Database from './src/Database'
|
|
12
11
|
import Mailer from './src/Mailer/Mailer'
|
|
13
12
|
import Router, { Route } from './src/Server/Router'
|
|
13
|
+
import AsyncSingleton from './src/Util/AsyncSingleton'
|
|
14
|
+
import Utils from './src/Util/Utils'
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* This module exports various classes and utilities for handling transactions, processes, events, routing,
|
|
@@ -50,6 +51,7 @@ export {
|
|
|
50
51
|
Response,
|
|
51
52
|
// Helpers
|
|
52
53
|
Utils,
|
|
54
|
+
AsyncSingleton,
|
|
53
55
|
Route,
|
|
54
56
|
// Misc types
|
|
55
57
|
ResponseErrorType,
|
package/package.json
CHANGED
package/src/API/Request.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context, APIGatewayEvent } from 'aws-lambda'
|
|
2
2
|
|
|
3
|
-
import Utils from './Utils'
|
|
4
3
|
import Logger from '../Logger/Logger'
|
|
4
|
+
import Utils from '../Util/Utils'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Represents a request object with generic types for input, query parameters, and path parameters.
|
package/src/Cache/Redis.ts
CHANGED
|
@@ -1,43 +1,26 @@
|
|
|
1
1
|
import { RedisClientType, createClient } from 'redis'
|
|
2
2
|
|
|
3
3
|
import { CacheConfig } from './types'
|
|
4
|
+
import AsyncSingleton from '../Util/AsyncSingleton'
|
|
4
5
|
/**
|
|
5
6
|
* Represents a Redis cache connection class.
|
|
6
7
|
*/
|
|
7
8
|
export default class Redis {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
private static singleton = new AsyncSingleton<RedisClientType, CacheConfig<'redis'>>(
|
|
10
|
+
Redis.redisConnection,
|
|
11
|
+
async c => c.isOpen
|
|
12
|
+
)
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
15
|
* A private static property that holds a reference to the redis.createClient function.
|
|
15
16
|
* This property is used to create client.
|
|
16
17
|
*/
|
|
17
18
|
private static ClientFactory = createClient
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
19
|
+
|
|
20
|
+
public static connection(config: CacheConfig<'redis'>): Promise<RedisClientType> {
|
|
21
|
+
return Redis.singleton.instance(config)
|
|
40
22
|
}
|
|
23
|
+
|
|
41
24
|
/**
|
|
42
25
|
* Establishes a connection to a Redis client based on the provided configuration
|
|
43
26
|
* and holds it for reusability. If connection is detected closed, new connection is
|
|
@@ -46,7 +29,6 @@ export default class Redis {
|
|
|
46
29
|
* @returns {Promise<RedisClientType>} A promise that resolves to the Redis client connection.
|
|
47
30
|
*/
|
|
48
31
|
private static async redisConnection(config: CacheConfig<'redis'>): Promise<RedisClientType> {
|
|
49
|
-
if (Redis._connection && Redis._connection.isOpen) return Redis._connection
|
|
50
32
|
console.debug('Starting remote cache connection')
|
|
51
33
|
const connection = Redis.ClientFactory({
|
|
52
34
|
username: config.username,
|
|
@@ -59,7 +41,7 @@ export default class Redis {
|
|
|
59
41
|
},
|
|
60
42
|
})
|
|
61
43
|
await connection.connect()
|
|
62
|
-
|
|
63
|
-
return
|
|
44
|
+
|
|
45
|
+
return connection as any
|
|
64
46
|
}
|
|
65
47
|
}
|
package/src/Globals.ts
CHANGED
package/src/Logger/Logger.ts
CHANGED
package/src/Server/Router.ts
CHANGED
|
@@ -7,12 +7,12 @@ import ContainerServer from './lib/ContainerServer'
|
|
|
7
7
|
import Server from './lib/Server'
|
|
8
8
|
import { HttpMethod } from '../API/Request'
|
|
9
9
|
import { ResponseErrorType } from '../API/Response'
|
|
10
|
-
import Utils from '../API/Utils'
|
|
11
10
|
import Transaction, {
|
|
12
11
|
TransactionConfig,
|
|
13
12
|
TransactionExecution,
|
|
14
13
|
StringMap,
|
|
15
14
|
} from '../BaseEvent/Transaction'
|
|
15
|
+
import Utils from '../Util/Utils'
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Represents a route in an API.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Request, Response } from 'express'
|
|
2
2
|
|
|
3
3
|
import GenericHandlerEvent, { GenericHandlerEventResponse } from './GenericHandlerEvent'
|
|
4
|
-
import Utils from '../../../API/Utils'
|
|
5
4
|
import Globals from '../../../Globals'
|
|
5
|
+
import Utils from '../../../Util/Utils'
|
|
6
6
|
import Server from '../Server'
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -7,8 +7,8 @@ import Server from './../Server'
|
|
|
7
7
|
import GenericHandler from './GenericHandler'
|
|
8
8
|
import HealthHandler from './HealthHandler'
|
|
9
9
|
import { version as appVersion } from '../../../../package.json'
|
|
10
|
-
import Utils from '../../../API/Utils'
|
|
11
10
|
import Globals from '../../../Globals'
|
|
11
|
+
import Utils from '../../../Util/Utils'
|
|
12
12
|
import { RouterConfig } from '../../Router'
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
type ResolveReject = [(value: void | PromiseLike<void>) => void, (reason?: any) => void]
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a class that can be used to create a singleton instance of a class that is created asynchronously.
|
|
5
|
+
*/
|
|
6
|
+
export default class AsyncSingleton<T, R> {
|
|
7
|
+
private readonly factory: (r: R) => Promise<T>
|
|
8
|
+
private readonly checker: (value: T) => Promise<boolean>
|
|
9
|
+
|
|
10
|
+
private queue: ResolveReject[] = []
|
|
11
|
+
private instantiating: boolean = false
|
|
12
|
+
|
|
13
|
+
private value?: T
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new instance of the AsyncSingleton class.
|
|
17
|
+
* @param factory The factory function that creates the instance.
|
|
18
|
+
* @param checker The function that checks if the instance is valid.
|
|
19
|
+
*/
|
|
20
|
+
public constructor(
|
|
21
|
+
factory: (r: R) => Promise<T>,
|
|
22
|
+
checker: (value: T) => Promise<boolean> = async () => true
|
|
23
|
+
) {
|
|
24
|
+
this.factory = factory
|
|
25
|
+
this.checker = checker
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets the instance of the class.
|
|
30
|
+
* @param r The configuration object for creating the instance.
|
|
31
|
+
*/
|
|
32
|
+
public async instance(r: R): Promise<T> {
|
|
33
|
+
if (this.value && (await this.checker(this.value))) return this.value
|
|
34
|
+
|
|
35
|
+
if (this.instantiating) {
|
|
36
|
+
return await this.awaitOtherInit()
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return await this.initHere(r)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Gets the current value, may be undefined or invalid.
|
|
44
|
+
*/
|
|
45
|
+
public getValue(): T | undefined {
|
|
46
|
+
return this.value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Clears the current value and rejects all pending promises.
|
|
51
|
+
*/
|
|
52
|
+
public clear() {
|
|
53
|
+
this.value = undefined
|
|
54
|
+
for (const [, rej] of this.queue) {
|
|
55
|
+
rej()
|
|
56
|
+
}
|
|
57
|
+
this.queue = []
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private async initHere(r: R): Promise<T> {
|
|
61
|
+
try {
|
|
62
|
+
this.instantiating = true
|
|
63
|
+
this.value = await this.factory(r)
|
|
64
|
+
|
|
65
|
+
for (const [res] of this.queue) {
|
|
66
|
+
res()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.queue = []
|
|
70
|
+
|
|
71
|
+
return this.value
|
|
72
|
+
} finally {
|
|
73
|
+
for (const [, rej] of this.queue) {
|
|
74
|
+
rej()
|
|
75
|
+
}
|
|
76
|
+
this.instantiating = false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private async awaitOtherInit(): Promise<T> {
|
|
81
|
+
await new Promise<void>((res, rej) => {
|
|
82
|
+
this.queue.push([res, rej])
|
|
83
|
+
})
|
|
84
|
+
return this.value!
|
|
85
|
+
}
|
|
86
|
+
}
|
package/tests/API/Utils.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Redis from '../../src/Cache/Redis'
|
|
2
2
|
|
|
3
3
|
let _connectionId = 1
|
|
4
|
+
|
|
4
5
|
async function simpleRedisTest(config: any, concurrent?: boolean) {
|
|
5
6
|
const RedisMock = jest.fn(() => {
|
|
6
7
|
let opened = false
|
|
@@ -20,18 +21,11 @@ async function simpleRedisTest(config: any, concurrent?: boolean) {
|
|
|
20
21
|
} as any
|
|
21
22
|
})
|
|
22
23
|
Redis['ClientFactory'] = RedisMock
|
|
23
|
-
// Cleanup previous connection
|
|
24
|
-
if (Redis['_connection']) (await Redis.connection({} as any))?.['close']()
|
|
25
24
|
// Double call is intentional
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
provider2 = ps[1]
|
|
31
|
-
} else {
|
|
32
|
-
provider = await Redis.connection(config as any)
|
|
33
|
-
provider2 = await Redis.connection(config as any)
|
|
34
|
-
}
|
|
25
|
+
const [provider, provider2] = concurrent
|
|
26
|
+
? await Promise.all([Redis.connection(config), Redis.connection(config)])
|
|
27
|
+
: [await Redis.connection(config), await Redis.connection(config)]
|
|
28
|
+
|
|
35
29
|
// client checks
|
|
36
30
|
expect(RedisMock).toHaveBeenNthCalledWith(1, {
|
|
37
31
|
username: config.username,
|
|
@@ -44,7 +38,7 @@ async function simpleRedisTest(config: any, concurrent?: boolean) {
|
|
|
44
38
|
},
|
|
45
39
|
})
|
|
46
40
|
// Does not have double connection
|
|
47
|
-
expect(provider
|
|
41
|
+
expect(provider['connectionId']).toEqual(provider2['connectionId'])
|
|
48
42
|
expect(provider.connect).toHaveBeenCalledTimes(1)
|
|
49
43
|
expect(provider2.connect).toHaveBeenCalledTimes(1)
|
|
50
44
|
}
|
|
@@ -52,10 +46,9 @@ async function simpleRedisTest(config: any, concurrent?: boolean) {
|
|
|
52
46
|
describe('Redis', () => {
|
|
53
47
|
beforeEach(async () => {
|
|
54
48
|
// hack to close singleton connection
|
|
55
|
-
if (Redis['
|
|
49
|
+
if (Redis['singleton'].getValue()) Redis['singleton'].clear()
|
|
56
50
|
})
|
|
57
51
|
test('Simple redis - do not connect twice', async () => {
|
|
58
|
-
Redis['_connection'] = null as any
|
|
59
52
|
await simpleRedisTest({
|
|
60
53
|
hostname: 'redis://localhost',
|
|
61
54
|
username: 'gabe',
|
|
@@ -65,7 +58,6 @@ describe('Redis', () => {
|
|
|
65
58
|
})
|
|
66
59
|
})
|
|
67
60
|
test('Simple redis (no SSL) - do not connect twice', async () => {
|
|
68
|
-
Redis['_connection'] = null as any
|
|
69
61
|
await simpleRedisTest({
|
|
70
62
|
hostname: 'redis://localhost',
|
|
71
63
|
username: 'gabe',
|
|
@@ -75,7 +67,6 @@ describe('Redis', () => {
|
|
|
75
67
|
})
|
|
76
68
|
})
|
|
77
69
|
test('Simple redis (passwordless) - do not connect twice', async () => {
|
|
78
|
-
Redis['_connection'] = null as any
|
|
79
70
|
await simpleRedisTest({
|
|
80
71
|
hostname: 'redis://localhost',
|
|
81
72
|
username: 'gabe',
|
|
@@ -84,7 +75,6 @@ describe('Redis', () => {
|
|
|
84
75
|
})
|
|
85
76
|
})
|
|
86
77
|
test('Concurrent redis - do not connect twice', async () => {
|
|
87
|
-
Redis['_connection'] = null as any
|
|
88
78
|
await simpleRedisTest(
|
|
89
79
|
{
|
|
90
80
|
hostname: 'redis://localhost',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../../src/API/Utils.ts"],"names":[],"mappings":";;AAAA;;GAEG;AACH;IAAA;IAwEA,CAAC;IAvEC;;;OAGG;IACW,2BAAqB,GAAnC;QACE,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,MAAM,CAAA;IACjD,CAAC;IAED;;;;OAIG;IACW,mBAAa,GAA3B,UAA4B,MAAc;QACxC,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,IAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrD,CAAC;IAED;;;;OAIG;IACW,uBAAiB,GAA/B,UAAgC,GAAY;QAC1C,IAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC,CAAA;QAC7B,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED;;;;;OAKG;IACW,4BAAsB,GAApC,UAAqC,MAA0B;QAC7D,IAAI,CAAC,GAAG,IAAI,CAAA;QACZ,IAAI,CAAC;YACH,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;YACtC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC;gBAAE,CAAC,GAAG,IAAI,CAAA;QAC/C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,WAAW;QACb,C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