@riocrypto/common-server 1.0.614 → 1.0.615
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/build/index.d.ts
CHANGED
|
@@ -30,7 +30,6 @@ export * from "./models/rio-settings";
|
|
|
30
30
|
export * from "./models/partner-auth";
|
|
31
31
|
export * from "./clients/bitstamp-client";
|
|
32
32
|
export * from "./clients/ccxt-client";
|
|
33
|
-
export * from "./clients/fixer-client";
|
|
34
33
|
export * from "./clients/kushki-client";
|
|
35
34
|
export * from "./clients/slack-client";
|
|
36
35
|
export * from "./clients/gueno-client";
|
package/build/index.js
CHANGED
|
@@ -46,7 +46,6 @@ __exportStar(require("./models/rio-settings"), exports);
|
|
|
46
46
|
__exportStar(require("./models/partner-auth"), exports);
|
|
47
47
|
__exportStar(require("./clients/bitstamp-client"), exports);
|
|
48
48
|
__exportStar(require("./clients/ccxt-client"), exports);
|
|
49
|
-
__exportStar(require("./clients/fixer-client"), exports);
|
|
50
49
|
__exportStar(require("./clients/kushki-client"), exports);
|
|
51
50
|
__exportStar(require("./clients/slack-client"), exports);
|
|
52
51
|
__exportStar(require("./clients/gueno-client"), exports);
|
package/package.json
CHANGED
|
@@ -1,55 +0,0 @@
|
|
|
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.buildFixerClient = void 0;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
const secret_manager_client_1 = require("./secret-manager-client");
|
|
18
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
19
|
-
const cache = new node_cache_1.default();
|
|
20
|
-
class FixerClient {
|
|
21
|
-
constructor(apiKey) {
|
|
22
|
-
this.apiKey = apiKey;
|
|
23
|
-
}
|
|
24
|
-
convert(from, to) {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
try {
|
|
27
|
-
const fixerResponse = yield axios_1.default.get(`https://api.apilayer.com/fixer/latest?base=${from}&symbols=${to}`, {
|
|
28
|
-
headers: {
|
|
29
|
-
apikey: this.apiKey,
|
|
30
|
-
"Accept-Encoding": "gzip,deflate,compress",
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
const exchangeRate = fixerResponse.data.rates[to] * 0.9987;
|
|
34
|
-
cache.set(`fixer/latest?base=${from}&symbols=${to}`, fixerResponse.data);
|
|
35
|
-
return exchangeRate;
|
|
36
|
-
}
|
|
37
|
-
catch (e) {
|
|
38
|
-
const cachedResponse = cache.get(`fixer/latest?base=${from}&symbols=${to}`);
|
|
39
|
-
if (!cachedResponse) {
|
|
40
|
-
throw new Error(`Unable to get exchange rate from Fixer for ${from} to ${to}`);
|
|
41
|
-
}
|
|
42
|
-
return cachedResponse.rates[to] * 0.9987;
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const buildFixerClient = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
const FIXER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("FIXER_API_KEY");
|
|
49
|
-
if (!FIXER_API_KEY) {
|
|
50
|
-
throw new Error("Unable to get FIXER_API_KEY");
|
|
51
|
-
}
|
|
52
|
-
// Create FixerClient instance and return
|
|
53
|
-
return new FixerClient(FIXER_API_KEY);
|
|
54
|
-
});
|
|
55
|
-
exports.buildFixerClient = buildFixerClient;
|