itrm-tools 1.0.45 → 1.0.46
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/api/APIRequest.d.ts +67 -67
- package/dist/api/APIRequest.js +145 -145
- package/dist/api/APIRequest.js.map +1 -1
- package/dist/api/APIRequestBuilder.d.ts +20 -20
- package/dist/api/APIRequestBuilder.js +14 -14
- package/dist/api/APIRouter.d.ts +11 -11
- package/dist/api/APIRouter.js +21 -21
- package/dist/api/APIService.d.ts +42 -42
- package/dist/api/APIService.js +108 -108
- package/dist/api/APIService.js.map +1 -1
- package/dist/api/ExpressConfiguration.d.ts +4 -4
- package/dist/api/ExpressConfiguration.js +2 -2
- package/dist/api/HttpsAPIService.d.ts +10 -10
- package/dist/api/HttpsAPIService.js +47 -47
- package/dist/api/channel/ServerSentEventsManager.d.ts +8 -8
- package/dist/api/channel/ServerSentEventsManager.js +25 -25
- package/dist/api/check/APIChecker.d.ts +26 -26
- package/dist/api/check/APIChecker.js +40 -40
- package/dist/api/check/CheckableAPIRequest.d.ts +9 -9
- package/dist/api/check/CheckableAPIRequest.js +44 -44
- package/dist/api/check/CheckableAPIRouter.d.ts +11 -11
- package/dist/api/check/CheckableAPIRouter.js +48 -48
- package/dist/api/check/request/CheckableDeleteRequest.d.ts +8 -8
- package/dist/api/check/request/CheckableDeleteRequest.js +17 -17
- package/dist/api/check/request/CheckableFileUploadingPostRequest.d.ts +11 -11
- package/dist/api/check/request/CheckableFileUploadingPostRequest.js +22 -22
- package/dist/api/check/request/CheckableGetRequest.d.ts +8 -8
- package/dist/api/check/request/CheckableGetRequest.js +17 -17
- package/dist/api/check/request/CheckablePostRequest.d.ts +8 -8
- package/dist/api/check/request/CheckablePostRequest.js +17 -17
- package/dist/api/check/request/CheckablePutRequest.d.ts +8 -8
- package/dist/api/check/request/CheckablePutRequest.js +17 -17
- package/dist/api/check/route/SimpleCheckableAPIRouter.d.ts +7 -7
- package/dist/api/check/route/SimpleCheckableAPIRouter.js +25 -25
- package/dist/api/express/ExpressFileUploadingConfiguration.d.ts +6 -6
- package/dist/api/express/ExpressFileUploadingConfiguration.js +27 -27
- package/dist/api/express/ExpressStandardConfiguration.d.ts +11 -11
- package/dist/api/express/ExpressStandardConfiguration.js +29 -29
- package/dist/api/request/DeleteRequest.d.ts +7 -7
- package/dist/api/request/DeleteRequest.js +16 -16
- package/dist/api/request/GetRequest.d.ts +7 -7
- package/dist/api/request/GetRequest.js +16 -16
- package/dist/api/request/PostRequest.d.ts +7 -7
- package/dist/api/request/PostRequest.js +16 -16
- package/dist/api/request/PutRequest.d.ts +7 -7
- package/dist/api/request/PutRequest.js +16 -16
- package/dist/api/request/RequestAxiosCall.d.ts +7 -7
- package/dist/api/request/RequestAxiosCall.js +57 -57
- package/dist/api/request/docs/DocumentationModels.d.ts +47 -47
- package/dist/api/request/docs/DocumentationModels.js +114 -114
- package/dist/api/request/docs/DocumentationRequest.d.ts +12 -12
- package/dist/api/request/docs/DocumentationRequest.js +126 -126
- package/dist/api/route/SimpleAPIRouter.d.ts +6 -6
- package/dist/api/route/SimpleAPIRouter.js +24 -24
- package/dist/database/mongoose/MongooseModelManager.d.ts +47 -43
- package/dist/database/mongoose/MongooseModelManager.js +65 -65
- package/dist/database/mongoose/MongooseModelManager.js.map +1 -1
- package/dist/database/redis/RedisConnection.d.ts +7 -7
- package/dist/database/redis/RedisConnection.js +17 -17
- package/dist/database/redis/RedisModelManager.d.ts +10 -10
- package/dist/database/redis/RedisModelManager.js +17 -17
- package/dist/database/sequelize/SequelizeConnection.d.ts +16 -16
- package/dist/database/sequelize/SequelizeConnection.js +22 -22
- package/dist/database/sequelize/SequelizeModelManager.d.ts +26 -26
- package/dist/database/sequelize/SequelizeModelManager.js +58 -58
- package/dist/index.d.ts +31 -31
- package/dist/index.js +67 -67
- package/dist/log/Logger.d.ts +7 -7
- package/dist/log/Logger.js +28 -28
- package/dist/log/LoggerManager.d.ts +7 -7
- package/dist/log/LoggerManager.js +63 -63
- package/dist/log/LoggerWebSocket.d.ts +10 -10
- package/dist/log/LoggerWebSocket.js +15 -15
- package/dist/web3/Coin.d.ts +18 -18
- package/dist/web3/Coin.js +22 -22
- package/dist/web3/Coin.js.map +1 -1
- package/dist/web3/coingecko/CoingeckoPriceFinder.d.ts +10 -10
- package/dist/web3/coingecko/CoingeckoPriceFinder.js +88 -88
- package/package.json +25 -25
|
@@ -1,89 +1,89 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CoingeckoPriceFinder = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const Coin_1 = require("../Coin");
|
|
18
|
-
class CoingeckoPriceFinder {
|
|
19
|
-
constructor(pair) {
|
|
20
|
-
this.prices = {};
|
|
21
|
-
this.pair = pair !== null && pair !== void 0 ? pair : "eth";
|
|
22
|
-
}
|
|
23
|
-
getPrice(symbol, date) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
date = date !== null && date !== void 0 ? date : new Date();
|
|
26
|
-
let id = this.parseSymbolId(symbol);
|
|
27
|
-
let key = (10000 * date.getFullYear()) + (100 * (date.getMonth() + 1)) + date.getDate();
|
|
28
|
-
return yield this.findPrice(id, "" + this.adjustDate(symbol, key));
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
adjustDate(symbol, date) {
|
|
32
|
-
switch (symbol) {
|
|
33
|
-
case Coin_1.Coin.APE: return Math.max(date, 20220317);
|
|
34
|
-
case Coin_1.Coin.ARTX: return Math.max(date, 20210404);
|
|
35
|
-
case Coin_1.Coin.ATRI: return Math.max(date, 20201102);
|
|
36
|
-
case Coin_1.Coin.BTC: return Math.max(date, 20130428);
|
|
37
|
-
case Coin_1.Coin.CUBE: return Math.max(date, 20200221);
|
|
38
|
-
case Coin_1.Coin.DAI: return Math.max(date, 20191119);
|
|
39
|
-
case Coin_1.Coin.MANA: return Math.max(date, 20171028);
|
|
40
|
-
case Coin_1.Coin.MATIC: return Math.max(date, 20190427);
|
|
41
|
-
case Coin_1.Coin.RARI: return Math.max(date, 20200717);
|
|
42
|
-
case Coin_1.Coin.SAND: return Math.max(date, 20200814);
|
|
43
|
-
case Coin_1.Coin.SCOTT: return Math.max(date, 20211220);
|
|
44
|
-
case Coin_1.Coin.USDC: return Math.max(date, 20181005);
|
|
45
|
-
case Coin_1.Coin.WBTC: return Math.max(date, 20130428);
|
|
46
|
-
default: return Math.max(date, 20150807);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
findPrice(symbol, date) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
-
let key = symbol + "_" + date;
|
|
52
|
-
if (!this.prices[key])
|
|
53
|
-
return new Promise((resolve, reject) => {
|
|
54
|
-
let url = "https://api.coingecko.com/api/v3/coins/" + symbol + "/history?date="
|
|
55
|
-
+ date.substring(6) + "-" + date.substring(4, 6) + "-" + date.substring(0, 4);
|
|
56
|
-
console.log("> url:", url);
|
|
57
|
-
axios_1.default.get(url, { headers: {
|
|
58
|
-
'Content-Type': 'application/json'
|
|
59
|
-
} }).then(response => {
|
|
60
|
-
if (response.data.market_data && response.data.market_data.current_price)
|
|
61
|
-
this.prices[key] = response.data.market_data.current_price[this.pair];
|
|
62
|
-
resolve(this.prices[key]);
|
|
63
|
-
}).catch(err => { resolve(this.prices[key]); });
|
|
64
|
-
});
|
|
65
|
-
return this.prices[key];
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
parseSymbolId(symbol) {
|
|
69
|
-
switch (symbol) {
|
|
70
|
-
case Coin_1.Coin.APE: return "apecoin";
|
|
71
|
-
case Coin_1.Coin.ARTX: return "artx";
|
|
72
|
-
case Coin_1.Coin.ATRI: return "atari";
|
|
73
|
-
case Coin_1.Coin.BTC: return "bitcoin";
|
|
74
|
-
case Coin_1.Coin.CUBE: return "somnium-space-cubes";
|
|
75
|
-
case Coin_1.Coin.DAI: return "dai";
|
|
76
|
-
case Coin_1.Coin.MANA: return "decentraland";
|
|
77
|
-
case Coin_1.Coin.MATIC: return "matic-network";
|
|
78
|
-
case Coin_1.Coin.RARI: return "rarible";
|
|
79
|
-
case Coin_1.Coin.SAND: return "the-sandbox";
|
|
80
|
-
case Coin_1.Coin.SCOTT: return "scotty-beam";
|
|
81
|
-
case Coin_1.Coin.USDC: return "usd-coin";
|
|
82
|
-
case Coin_1.Coin.USDT: return "tether";
|
|
83
|
-
case Coin_1.Coin.WBTC: return "bitcoin";
|
|
84
|
-
default: return "ethereum";
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.CoingeckoPriceFinder = CoingeckoPriceFinder;
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CoingeckoPriceFinder = void 0;
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
|
+
const Coin_1 = require("../Coin");
|
|
18
|
+
class CoingeckoPriceFinder {
|
|
19
|
+
constructor(pair) {
|
|
20
|
+
this.prices = {};
|
|
21
|
+
this.pair = pair !== null && pair !== void 0 ? pair : "eth";
|
|
22
|
+
}
|
|
23
|
+
getPrice(symbol, date) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
date = date !== null && date !== void 0 ? date : new Date();
|
|
26
|
+
let id = this.parseSymbolId(symbol);
|
|
27
|
+
let key = (10000 * date.getFullYear()) + (100 * (date.getMonth() + 1)) + date.getDate();
|
|
28
|
+
return yield this.findPrice(id, "" + this.adjustDate(symbol, key));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
adjustDate(symbol, date) {
|
|
32
|
+
switch (symbol) {
|
|
33
|
+
case Coin_1.Coin.APE: return Math.max(date, 20220317);
|
|
34
|
+
case Coin_1.Coin.ARTX: return Math.max(date, 20210404);
|
|
35
|
+
case Coin_1.Coin.ATRI: return Math.max(date, 20201102);
|
|
36
|
+
case Coin_1.Coin.BTC: return Math.max(date, 20130428);
|
|
37
|
+
case Coin_1.Coin.CUBE: return Math.max(date, 20200221);
|
|
38
|
+
case Coin_1.Coin.DAI: return Math.max(date, 20191119);
|
|
39
|
+
case Coin_1.Coin.MANA: return Math.max(date, 20171028);
|
|
40
|
+
case Coin_1.Coin.MATIC: return Math.max(date, 20190427);
|
|
41
|
+
case Coin_1.Coin.RARI: return Math.max(date, 20200717);
|
|
42
|
+
case Coin_1.Coin.SAND: return Math.max(date, 20200814);
|
|
43
|
+
case Coin_1.Coin.SCOTT: return Math.max(date, 20211220);
|
|
44
|
+
case Coin_1.Coin.USDC: return Math.max(date, 20181005);
|
|
45
|
+
case Coin_1.Coin.WBTC: return Math.max(date, 20130428);
|
|
46
|
+
default: return Math.max(date, 20150807);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
findPrice(symbol, date) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let key = symbol + "_" + date;
|
|
52
|
+
if (!this.prices[key])
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
let url = "https://api.coingecko.com/api/v3/coins/" + symbol + "/history?date="
|
|
55
|
+
+ date.substring(6) + "-" + date.substring(4, 6) + "-" + date.substring(0, 4);
|
|
56
|
+
console.log("> url:", url);
|
|
57
|
+
axios_1.default.get(url, { headers: {
|
|
58
|
+
'Content-Type': 'application/json'
|
|
59
|
+
} }).then(response => {
|
|
60
|
+
if (response.data.market_data && response.data.market_data.current_price)
|
|
61
|
+
this.prices[key] = response.data.market_data.current_price[this.pair];
|
|
62
|
+
resolve(this.prices[key]);
|
|
63
|
+
}).catch(err => { resolve(this.prices[key]); });
|
|
64
|
+
});
|
|
65
|
+
return this.prices[key];
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
parseSymbolId(symbol) {
|
|
69
|
+
switch (symbol) {
|
|
70
|
+
case Coin_1.Coin.APE: return "apecoin";
|
|
71
|
+
case Coin_1.Coin.ARTX: return "artx";
|
|
72
|
+
case Coin_1.Coin.ATRI: return "atari";
|
|
73
|
+
case Coin_1.Coin.BTC: return "bitcoin";
|
|
74
|
+
case Coin_1.Coin.CUBE: return "somnium-space-cubes";
|
|
75
|
+
case Coin_1.Coin.DAI: return "dai";
|
|
76
|
+
case Coin_1.Coin.MANA: return "decentraland";
|
|
77
|
+
case Coin_1.Coin.MATIC: return "matic-network";
|
|
78
|
+
case Coin_1.Coin.RARI: return "rarible";
|
|
79
|
+
case Coin_1.Coin.SAND: return "the-sandbox";
|
|
80
|
+
case Coin_1.Coin.SCOTT: return "scotty-beam";
|
|
81
|
+
case Coin_1.Coin.USDC: return "usd-coin";
|
|
82
|
+
case Coin_1.Coin.USDT: return "tether";
|
|
83
|
+
case Coin_1.Coin.WBTC: return "bitcoin";
|
|
84
|
+
default: return "ethereum";
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.CoingeckoPriceFinder = CoingeckoPriceFinder;
|
|
89
89
|
//# sourceMappingURL=CoingeckoPriceFinder.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itrm-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.46",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -31,39 +31,39 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/ITRMachines/itrm-tools#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/jest": "^29.
|
|
35
|
-
"@types/multer": "^1.4.
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"@types/swagger-ui-express": "^4.1.
|
|
38
|
-
"@types/uuid": "^9.0.
|
|
39
|
-
"axios-mock-adapter": "^1.
|
|
40
|
-
"jest": "^29.
|
|
41
|
-
"jest-puppeteer": "^9.0.
|
|
42
|
-
"mongodb-memory-server": "^
|
|
43
|
-
"puppeteer": "^
|
|
44
|
-
"rimraf": "^
|
|
45
|
-
"sqlite3": "^5.1.
|
|
46
|
-
"ts-jest": "^29.
|
|
47
|
-
"typescript": "^
|
|
48
|
-
"uuid": "^9.0.
|
|
34
|
+
"@types/jest": "^29.5.6",
|
|
35
|
+
"@types/multer": "^1.4.9",
|
|
36
|
+
"@types/node": "^20.8.7",
|
|
37
|
+
"@types/swagger-ui-express": "^4.1.5",
|
|
38
|
+
"@types/uuid": "^9.0.6",
|
|
39
|
+
"axios-mock-adapter": "^1.22.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"jest-puppeteer": "^9.0.1",
|
|
42
|
+
"mongodb-memory-server": "^9.0.1",
|
|
43
|
+
"puppeteer": "^21.4.0",
|
|
44
|
+
"rimraf": "^5.0.5",
|
|
45
|
+
"sqlite3": "^5.1.6",
|
|
46
|
+
"ts-jest": "^29.1.1",
|
|
47
|
+
"typescript": "^5.2.2",
|
|
48
|
+
"uuid": "^9.0.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@sequelize/core": "^7.0.0-alpha.10",
|
|
52
|
-
"@types/cors": "^2.8.
|
|
53
|
-
"@types/express": "^4.17.
|
|
54
|
-
"@types/ws": "^8.5.
|
|
55
|
-
"axios": "^1.
|
|
56
|
-
"axios-retry": "^3.
|
|
52
|
+
"@types/cors": "^2.8.15",
|
|
53
|
+
"@types/express": "^4.17.20",
|
|
54
|
+
"@types/ws": "^8.5.8",
|
|
55
|
+
"axios": "^1.5.1",
|
|
56
|
+
"axios-retry": "^3.8.0",
|
|
57
57
|
"body-parser": "^1.20.2",
|
|
58
58
|
"cors": "^2.8.5",
|
|
59
59
|
"express": "^4.18.2",
|
|
60
60
|
"https": "^1.0.0",
|
|
61
|
-
"mongoose": "^6.
|
|
61
|
+
"mongoose": "^7.6.3",
|
|
62
62
|
"multer": "^1.4.5-lts.1",
|
|
63
|
-
"pg": "^8.
|
|
63
|
+
"pg": "^8.11.3",
|
|
64
64
|
"pg-hstore": "^2.3.4",
|
|
65
|
-
"redis": "^4.
|
|
65
|
+
"redis": "^4.6.10",
|
|
66
66
|
"swagger-ui-express": "^5.0.0",
|
|
67
|
-
"ws": "^8.
|
|
67
|
+
"ws": "^8.14.2"
|
|
68
68
|
}
|
|
69
69
|
}
|