@beblurt/blurt-nodes-checker 1.0.0

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.
Files changed (37) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +318 -0
  3. package/dist/blurt-nodes-checker.min.js +23 -0
  4. package/lib/helpers/BLOCK_API/GET_BLOCK.d.ts +26 -0
  5. package/lib/helpers/BLOCK_API/GET_BLOCK.js +2 -0
  6. package/lib/helpers/BLOCK_API/GET_BLOCK.js.map +1 -0
  7. package/lib/helpers/CONDENSER_API/DYNAMIC_GLOBAL_PROPERTIES.d.ts +67 -0
  8. package/lib/helpers/CONDENSER_API/DYNAMIC_GLOBAL_PROPERTIES.js +2 -0
  9. package/lib/helpers/CONDENSER_API/DYNAMIC_GLOBAL_PROPERTIES.js.map +1 -0
  10. package/lib/helpers/CONDENSER_API/GET_ACCOUNT.d.ts +73 -0
  11. package/lib/helpers/CONDENSER_API/GET_ACCOUNT.js +2 -0
  12. package/lib/helpers/CONDENSER_API/GET_ACCOUNT.js.map +1 -0
  13. package/lib/helpers/CONDENSER_API/GET_BLOG_ENTRY.d.ts +7 -0
  14. package/lib/helpers/CONDENSER_API/GET_BLOG_ENTRY.js +2 -0
  15. package/lib/helpers/CONDENSER_API/GET_BLOG_ENTRY.js.map +1 -0
  16. package/lib/helpers/CONDENSER_API/GET_CONFIG.d.ts +174 -0
  17. package/lib/helpers/CONDENSER_API/GET_CONFIG.js +2 -0
  18. package/lib/helpers/CONDENSER_API/GET_CONFIG.js.map +1 -0
  19. package/lib/helpers/CONDENSER_API/GET_CONTENT.d.ts +54 -0
  20. package/lib/helpers/CONDENSER_API/GET_CONTENT.js +2 -0
  21. package/lib/helpers/CONDENSER_API/GET_CONTENT.js.map +1 -0
  22. package/lib/helpers/CONDENSER_API/GET_DISCUSSION.d.ts +39 -0
  23. package/lib/helpers/CONDENSER_API/GET_DISCUSSION.js +2 -0
  24. package/lib/helpers/CONDENSER_API/GET_DISCUSSION.js.map +1 -0
  25. package/lib/helpers/index.d.ts +54 -0
  26. package/lib/helpers/index.js +2 -0
  27. package/lib/helpers/index.js.map +1 -0
  28. package/lib/hrtime.d.ts +1 -0
  29. package/lib/hrtime.js +29 -0
  30. package/lib/hrtime.js.map +1 -0
  31. package/lib/index.d.ts +43 -0
  32. package/lib/index.js +337 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/test.d.ts +22 -0
  35. package/lib/test.js +53 -0
  36. package/lib/test.js.map +1 -0
  37. package/package.json +61 -0
package/lib/index.js ADDED
@@ -0,0 +1,337 @@
1
+ /**
2
+ * @project @beblurt/blurt-nodes-checker
3
+ * @author @beblurt (https://blurt.blog/@beblurt)
4
+ * @license
5
+ * Copyright (C) 2022 IMT ASE Co., LTD
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+ /** Axios */
21
+ import axios from "axios";
22
+ /** RxJS */
23
+ import { Subject } from "rxjs";
24
+ /** Process hrtime for browser (node + fallback) */
25
+ import { hrtime } from "./hrtime.js";
26
+ /** Test list to proceed */
27
+ import { testList } from "./test.js";
28
+ const RegExpUrl = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,=.]+$/;
29
+ export class BlurtNodesChecker {
30
+ constructor(nodes, options) {
31
+ Object.defineProperty(this, "nodes", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: []
36
+ });
37
+ Object.defineProperty(this, "message", {
38
+ enumerable: true,
39
+ configurable: true,
40
+ writable: true,
41
+ value: new Subject()
42
+ });
43
+ Object.defineProperty(this, "timer", {
44
+ enumerable: true,
45
+ configurable: true,
46
+ writable: true,
47
+ value: void 0
48
+ });
49
+ Object.defineProperty(this, "full", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: false
54
+ });
55
+ Object.defineProperty(this, "interval", {
56
+ enumerable: true,
57
+ configurable: true,
58
+ writable: true,
59
+ value: 900000
60
+ });
61
+ Object.defineProperty(this, "timeout", {
62
+ enumerable: true,
63
+ configurable: true,
64
+ writable: true,
65
+ value: 3000
66
+ });
67
+ Object.defineProperty(this, "reset", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ Object.defineProperty(this, "instance", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: axios.default.create()
78
+ });
79
+ Object.defineProperty(this, "intercept", {
80
+ enumerable: true,
81
+ configurable: true,
82
+ writable: true,
83
+ value: void 0
84
+ });
85
+ Object.defineProperty(this, "tests", {
86
+ enumerable: true,
87
+ configurable: true,
88
+ writable: true,
89
+ value: testList(20000000, "blurtofficial", "blurt-hardfork-0-8-a-new-consensus")
90
+ });
91
+ if (options) {
92
+ if (options.full && (typeof options.full) === 'boolean')
93
+ this.full = options.full;
94
+ if (options.interval && typeof options.interval === 'number')
95
+ this.interval = options.interval * 1000;
96
+ if (options.timeout && typeof options.timeout === 'number')
97
+ this.timeout = options.timeout * 1000;
98
+ if (options.reset && typeof options.reset === 'number')
99
+ this.reset = options.reset;
100
+ }
101
+ for (const node of nodes) {
102
+ const isUrlValid = new RegExp(RegExpUrl);
103
+ if (isUrlValid.test(node)) {
104
+ this.nodes.push({
105
+ url: node,
106
+ nb_ok: 0,
107
+ nb_error: 0,
108
+ nb_degraded: 0,
109
+ last_check: Date.now(),
110
+ status: "unkown",
111
+ test_result: []
112
+ });
113
+ }
114
+ else {
115
+ this.message.error(new Error(`${node} is not a valid url`));
116
+ }
117
+ }
118
+ }
119
+ async start() {
120
+ try {
121
+ this.instance.interceptors.request.use((config) => {
122
+ if (config && config.headers && config.headers["starttime"])
123
+ delete config.headers["starttime"];
124
+ return config;
125
+ }, (error) => {
126
+ return Promise.reject(error);
127
+ });
128
+ if (this.nodes.length > 0) {
129
+ setTimeout(() => {
130
+ this.check();
131
+ }, 25);
132
+ this.timer = setInterval(async () => {
133
+ this.check();
134
+ }, this.interval);
135
+ }
136
+ }
137
+ catch (error) {
138
+ clearInterval(this.timer);
139
+ this.message.error(error.message);
140
+ }
141
+ }
142
+ stop() {
143
+ clearInterval(this.timer);
144
+ }
145
+ restart() {
146
+ clearInterval(this.timer);
147
+ this.start();
148
+ }
149
+ async check() {
150
+ /** Define the execution time (used for sendMessage) */
151
+ const checkTime = Date.now();
152
+ /** Node Loop */
153
+ for (const [i, node] of this.nodes.entries()) {
154
+ if (this.nodes[i]) {
155
+ /** We reach the reset number of tests => reinit counters value */
156
+ if (this.reset && (node.nb_ok + node.nb_error + node.nb_degraded) === this.reset) {
157
+ this.nodes[i].nb_ok = 0;
158
+ this.nodes[i].nb_error = 0;
159
+ this.nodes[i].nb_degraded = 0;
160
+ }
161
+ /** hrtime */
162
+ const startRequestNode = hrtime();
163
+ /** First request to BLURT node (light test) */
164
+ const options = {
165
+ method: "post",
166
+ url: node.url,
167
+ headers: {
168
+ "Content-Type": "application/json"
169
+ },
170
+ data: {
171
+ jsonrpc: "2.0",
172
+ method: "condenser_api.get_config",
173
+ params: [],
174
+ id: 1
175
+ },
176
+ timeout: this.timeout
177
+ };
178
+ this.instance(options).then(async (get_config) => {
179
+ /** hrtime */
180
+ const stopRequestNode = hrtime(startRequestNode);
181
+ const milli = (stopRequestNode[0] * 1e9 + stopRequestNode[1]) / 1e6;
182
+ const config = get_config.data;
183
+ if (config.error)
184
+ throw new Error(config.error.message);
185
+ if (config.result) {
186
+ this.nodes[i].nb_ok++;
187
+ this.nodes[i].status = "online";
188
+ this.nodes[i].version = config.result.BLURT_BLOCKCHAIN_VERSION;
189
+ this.nodes[i].duration = Math.round(milli);
190
+ /** Execute a full test */
191
+ if (this.full) {
192
+ /** Test Loop */
193
+ for (const test of this.tests) {
194
+ /** hrtime */
195
+ const startRequestTest = hrtime();
196
+ /** Check if previous test */
197
+ const tIndex = node.test_result.findIndex(t => t.method === test.method);
198
+ /** Execute the test */
199
+ const options = {
200
+ method: "post",
201
+ url: node.url,
202
+ headers: {
203
+ "Content-Type": "application/json"
204
+ },
205
+ data: {
206
+ jsonrpc: "2.0",
207
+ method: test.method,
208
+ params: test.params,
209
+ id: 1
210
+ },
211
+ timeout: this.timeout
212
+ };
213
+ this.instance(options).then(get_config => {
214
+ /** hrtime */
215
+ const stopRequestStop = hrtime(startRequestTest);
216
+ const milli = (stopRequestStop[0] * 1e9 + stopRequestStop[1]) / 1e6;
217
+ const config = get_config.data ? get_config.data : null;
218
+ const success = config && config.result && test.validator ? test.validator(config.result) : false;
219
+ /** Result of the test */
220
+ const r = {
221
+ name: test.name,
222
+ description: test.description,
223
+ method: test.method,
224
+ success: success,
225
+ duration: Math.round(milli),
226
+ last_check: checkTime
227
+ };
228
+ /** If test validation failed */
229
+ if (!success) {
230
+ r.error = config && config.error ? config.error.message : "validation failed!";
231
+ /** update status of node */
232
+ this.nodes[i].status = "degraded";
233
+ /** update degraded counter */
234
+ this.nodes[i].nb_degraded++;
235
+ /** correct OK counter */
236
+ if (this.nodes[i].nb_ok > 0)
237
+ this.nodes[i].nb_ok--;
238
+ /** Update average time */
239
+ delete this.nodes[i].average_time;
240
+ }
241
+ else {
242
+ /** update status of node */
243
+ if (this.nodes[i].status !== "degraded") {
244
+ this.nodes[i].status = "online";
245
+ }
246
+ /** Update average time */
247
+ this.nodes[i].average_time = this.nodes[i].average_time ? Math.round((this.nodes[i].average_time + r.duration) / 2) : r.duration;
248
+ }
249
+ /** If old result update else add */
250
+ if (tIndex >= 0) {
251
+ this.nodes[i].test_result[tIndex] = r;
252
+ }
253
+ else {
254
+ this.nodes[i].test_result.push(r);
255
+ }
256
+ /** End of tests for the node? */
257
+ const nbTest = this.nodes[i].test_result.filter(n => n.last_check === checkTime);
258
+ if (nbTest.length === this.tests.length) {
259
+ /** assign the execution time */
260
+ this.nodes[i].last_check = checkTime;
261
+ /** Send message? */
262
+ this.sendMessage(checkTime);
263
+ }
264
+ }).catch(error => {
265
+ /** Result of the test */
266
+ const r = {
267
+ name: test.name,
268
+ description: test.description,
269
+ method: test.method,
270
+ success: false,
271
+ duration: 999999,
272
+ last_check: checkTime,
273
+ error: error.message
274
+ };
275
+ /** update status of node */
276
+ this.nodes[i].status = "degraded";
277
+ /** update degraded counter */
278
+ this.nodes[i].nb_degraded++;
279
+ /** correct OK counter */
280
+ this.nodes[i].nb_ok--;
281
+ /** If old result update else add */
282
+ if (tIndex >= 0) {
283
+ this.nodes[i].test_result[tIndex] = r;
284
+ }
285
+ else {
286
+ this.nodes[i].test_result.push(r);
287
+ }
288
+ /** Update average time */
289
+ delete this.nodes[i].average_time;
290
+ /** End of tests for the node? */
291
+ const nbTest = this.nodes[i].test_result.filter(n => n.last_check === checkTime);
292
+ if (nbTest.length === this.tests.length) {
293
+ /** assign the execution time */
294
+ this.nodes[i].last_check = checkTime;
295
+ /** Send message? */
296
+ this.sendMessage(checkTime);
297
+ }
298
+ });
299
+ }
300
+ }
301
+ else {
302
+ /** assign the execution time */
303
+ this.nodes[i].last_check = checkTime;
304
+ /** Send message? */
305
+ this.sendMessage(checkTime);
306
+ }
307
+ }
308
+ else {
309
+ this.nodes[i].nb_error++;
310
+ this.nodes[i].status = "error";
311
+ this.nodes[i].error = "No result!";
312
+ /** assign the execution time */
313
+ this.nodes[i].last_check = checkTime;
314
+ /** Send message? */
315
+ this.sendMessage(checkTime);
316
+ }
317
+ }).catch(error => {
318
+ this.nodes[i].nb_error++;
319
+ this.nodes[i].status = "error";
320
+ if (error)
321
+ this.nodes[i].error = error.message;
322
+ /** assign the execution time */
323
+ this.nodes[i].last_check = checkTime;
324
+ /** Send message? */
325
+ this.sendMessage(checkTime);
326
+ });
327
+ }
328
+ }
329
+ }
330
+ async sendMessage(checkTime) {
331
+ /** Send message? */
332
+ const nbNodeChecked = this.nodes.filter(n => n.last_check === checkTime);
333
+ if (this.nodes.length === nbNodeChecked.length)
334
+ this.message.next(this.nodes);
335
+ }
336
+ }
337
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,YAAY;AACZ,OAAO,KAA6B,MAAM,OAAO,CAAA;AAEjD,WAAW;AACX,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,mDAAmD;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,2BAA2B;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAYrC,MAAM,SAAS,GAAG,wEAAwE,CAAA;AAE1F,MAAM,OAAO,iBAAiB;IAe5B,YAAY,KAAe,EAAE,OAAgB;QAd7C;;;;mBAAoB,EAAE;WAAA;QACtB;;;;mBAAU,IAAI,OAAO,EAAc;WAAA;QACnC;;;;;WAAqC;QAErC;;;;mBAAW,KAAK;WAAA;QAChB;;;;mBAAW,MAAM;WAAA;QACjB;;;;mBAAW,IAAI;WAAA;QACf;;;;;WAAc;QAEd;;;;mBAAW,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;WAAA;QACjC;;;;;WAAkB;QAElB;;;;mBAAqB,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,oCAAoC,CAAC;WAAA;QAG5F,IAAG,OAAO,EAAE;YACV,IAAG,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,SAAS;gBAAE,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;YAChF,IAAG,OAAO,CAAC,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,MAAM,KAAK,aAAa,CAAC,MAAM;YAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC9E,CAAC;CACF"}
package/lib/test.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @project @beblurt/blurt-nodes-checker
3
+ * @author @beblurt (https://blurt.blog/@beblurt)
4
+ * @license
5
+ * Copyright (C) 2022 IMT ASE Co., LTD
6
+ *
7
+ * This program is free software: you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation, either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License
18
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ */
20
+ /** TYPE */
21
+ import { FULL_TEST } from "./helpers/index.js";
22
+ export declare const testList: (block: number, account: string, permlink: string) => FULL_TEST[];
package/lib/test.js ADDED
@@ -0,0 +1,53 @@
1
+ export const testList = (block, account, permlink) => {
2
+ return [
3
+ {
4
+ name: "Block_API | Get Block",
5
+ description: "Get Block",
6
+ method: "block_api.get_block",
7
+ params: { block_num: block },
8
+ validator: (result) => {
9
+ return result.block.witness ? true : false;
10
+ }
11
+ },
12
+ {
13
+ name: "Condenser_API | Get Account",
14
+ description: "Retrieve an account details",
15
+ method: "condenser_api.get_accounts",
16
+ params: [[account]],
17
+ validator: (result) => Array.isArray(result) && result.length > 0 ? true : false
18
+ },
19
+ {
20
+ name: "Condenser_API | Get Blog Entries",
21
+ description: "Retrieve the list of blog entries for an account)",
22
+ method: "condenser_api.get_blog_entries",
23
+ params: [account, 0, 25],
24
+ validator: (result) => Array.isArray(result) && result.length > 0 ? true : false
25
+ },
26
+ {
27
+ name: "Condenser_API | Get Content",
28
+ description: "Retrieve the content (post or comment))",
29
+ method: "condenser_api.get_content",
30
+ params: [account, permlink],
31
+ validator: (result) => {
32
+ return result.created ? true : false;
33
+ }
34
+ },
35
+ {
36
+ name: "Condenser_API | Get Dynamic Global Propertie",
37
+ description: "Check chain global properties",
38
+ method: "condenser_api.get_dynamic_global_properties",
39
+ params: [],
40
+ validator: (result) => {
41
+ return "head_block_number" in result && "last_irreversible_block_num" in result ? true : false;
42
+ }
43
+ },
44
+ {
45
+ name: "Condenser_API | Get Disccusion By Blog",
46
+ description: "Retrieve a list of discussions by blog)",
47
+ method: "condenser_api.get_discussions_by_blog",
48
+ params: [{ tag: account, limit: 5, truncate_body: 1 }],
49
+ validator: (result) => Array.isArray(result) && result.length > 0 ? true : false
50
+ },
51
+ ];
52
+ };
53
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,OAAe,EAAE,QAAgB,EAAe,EAAE;IACxF,OAAO;QACL;YACE,IAAI,EAAE,uBAAuB;YAC7B,WAAW,EAAE,WAAW;YACxB,MAAM,EAAE,qBAAqB;YAC7B,MAAM,EAAE,EAAC,SAAS,EAAE,KAAK,EAAC;YAC1B,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;gBACpB,OAAQ,MAA0B,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAA;YACjE,CAAC;SACF;QACD;YACE,IAAI,EAAE,6BAA6B;YACnC,WAAW,EAAE,6BAA6B;YAC1C,MAAM,EAAE,4BAA4B;YACpC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;YACnB,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAuB,CAAC,IAAK,MAAwB,CAAC,MAAM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IAAK,MAA2B,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;SAC5H;KACF,CAAA;AACH,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@beblurt/blurt-nodes-checker",
3
+ "version": "1.0.0",
4
+ "description": "BLURT blockchain RPC nodes servers checker (latency, availability, methods)",
5
+ "type": "module",
6
+ "node": ">=14.16",
7
+ "exports": "./lib/index.js",
8
+ "typings": "./lib/index.d.ts",
9
+ "files": [
10
+ "dist/*",
11
+ "lib/*"
12
+ ],
13
+ "scripts": {
14
+ "commit": "git-cz",
15
+ "release": "standard-version",
16
+ "test": "echo \"Error: no test specified\" && exit 1",
17
+ "build": "tsc --declaration",
18
+ "build-browser": "node ./build.js"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://gitlab.com/beblurt/blurt-nodes-checker.git"
23
+ },
24
+ "keywords": [
25
+ "blurt",
26
+ "blurt checker",
27
+ "blurt nodes checker",
28
+ "blurt rpc nodes",
29
+ "blurt rpc",
30
+ "blurt blockchain"
31
+ ],
32
+ "author": "@beblurt (https://blurt.blog/@beblurt)",
33
+ "license": "GPL-3.0-or-later",
34
+ "bugs": {
35
+ "url": "https://gitlab.com/beblurt/blurt-nodes-checker/issues"
36
+ },
37
+ "homepage": "https://gitlab.com/beblurt/blurt-nodes-checker#readme",
38
+ "devDependencies": {
39
+ "@types/node": "^17.0.5",
40
+ "@typescript-eslint/eslint-plugin": "^5.35.1",
41
+ "@typescript-eslint/parser": "^5.35.1",
42
+ "commitizen": "^4.2.5",
43
+ "esbuild": "^0.15.5",
44
+ "eslint": "^8.23.0",
45
+ "prettier": "^2.7.1",
46
+ "standard-version": "^9.5.0",
47
+ "typescript": "^4.8.2"
48
+ },
49
+ "dependencies": {
50
+ "axios": "^0.27.2",
51
+ "rxjs": "^7.5.6"
52
+ },
53
+ "contributors": [
54
+ "@beblurt (https://blurt.blog/@beblurt)"
55
+ ],
56
+ "config": {
57
+ "commitizen": {
58
+ "path": "./node_modules/cz-conventional-changelog"
59
+ }
60
+ }
61
+ }