@riocrypto/common-server 1.0.1229 → 1.0.1230

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.
@@ -1,8 +1,9 @@
1
1
  import { Quote, Fiat, Crypto, BitsoBankAccount } from "@riocrypto/common";
2
2
  declare class ClusterClient {
3
+ private baseUrl;
3
4
  private clusterApiKey;
4
5
  private axios;
5
- constructor(clusterApiKey: string);
6
+ constructor(baseUrl: string, clusterApiKey: string);
6
7
  getNewQuote(orderId: string, quote: Quote, newAmountFiat?: number, newAmountCrypto?: number): Promise<Quote>;
7
8
  createBitsoBankAccount(userId: string): Promise<BitsoBankAccount>;
8
9
  getBalance(asset: Crypto | Fiat): Promise<number>;
@@ -17,9 +17,21 @@ const common_1 = require("@riocrypto/common");
17
17
  const axios_1 = __importDefault(require("axios"));
18
18
  const secret_manager_client_1 = require("./secret-manager-client");
19
19
  class ClusterClient {
20
- constructor(clusterApiKey) {
20
+ constructor(baseUrl, clusterApiKey) {
21
+ this.baseUrl = baseUrl;
21
22
  this.clusterApiKey = clusterApiKey;
22
- this.axios = axios_1.default.create({});
23
+ this.axios = axios_1.default.create({
24
+ baseURL: baseUrl,
25
+ headers: {
26
+ Host: process.env.RIO_ENV === common_1.RioEnv.Development
27
+ ? "dev.riotransfer.co"
28
+ : process.env.RIO_ENV === common_1.RioEnv.Staging
29
+ ? "staging.riotransfer.co"
30
+ : process.env.RIO_ENV === common_1.RioEnv.Sandbox
31
+ ? "sandbox.riotransfer.co"
32
+ : "www.riotransfer.co",
33
+ },
34
+ });
23
35
  }
24
36
  getNewQuote(orderId, quote, newAmountFiat, newAmountCrypto) {
25
37
  return __awaiter(this, void 0, void 0, function* () {
@@ -43,7 +55,7 @@ class ClusterClient {
43
55
  amountCrypto = undefined;
44
56
  }
45
57
  }
46
- const response = yield this.axios.post(`/api/quotes`, {
58
+ const response = yield this.axios.post(`${this.baseUrl}/api/quotes`, {
47
59
  orderId,
48
60
  userId: quote.userId,
49
61
  side: quote.side,
@@ -65,7 +77,7 @@ class ClusterClient {
65
77
  }
66
78
  createBitsoBankAccount(userId) {
67
79
  return __awaiter(this, void 0, void 0, function* () {
68
- const response = yield this.axios.post(`/api/bank/accounts/bitso`, {
80
+ const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/bitso`, {
69
81
  userId,
70
82
  }, {
71
83
  headers: {
@@ -77,7 +89,7 @@ class ClusterClient {
77
89
  }
78
90
  getBalance(asset) {
79
91
  return __awaiter(this, void 0, void 0, function* () {
80
- const rioResponse = yield this.axios.get(`/api/liquidity/${asset}`, {
92
+ const rioResponse = yield this.axios.get(`${this.baseUrl}/api/liquidity/${asset}`, {
81
93
  headers: {
82
94
  "x-cluster-api-key": this.clusterApiKey,
83
95
  },
@@ -92,6 +104,13 @@ const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* ()
92
104
  if (!CLUSTER_API_KEY) {
93
105
  throw new common_1.SecretManagerError();
94
106
  }
95
- return new ClusterClient(CLUSTER_API_KEY);
107
+ const baseUrl = process.env.RIO_ENV === common_1.RioEnv.Development
108
+ ? "https://dev.riotransfer.co"
109
+ : process.env.RIO_ENV === common_1.RioEnv.Production
110
+ ? "https://www.riotransfer.co"
111
+ : process.env.RIO_ENV === common_1.RioEnv.Staging
112
+ ? "https://staging.riotransfer.co"
113
+ : "https://sandbox.riotransfer.co";
114
+ return new ClusterClient(baseUrl, CLUSTER_API_KEY);
96
115
  });
97
116
  exports.buildClusterClient = buildClusterClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1229",
3
+ "version": "1.0.1230",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",