forked from bigearth/bitbox-cli
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from Bitcoin-com/stage
v8.6.0
- Loading branch information
Showing
4 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// imports | ||
import axios, { AxiosResponse } from "axios" | ||
import { BITDB_URL } from "./BITBOX" | ||
import { BitDBResponse, QueryInterface } from "./interfaces/BITBOXInterfaces" | ||
|
||
// consts | ||
const Buffer = require("safe-buffer").Buffer | ||
|
||
export class BitDB { | ||
public bitdbURL: string | ||
constructor(bitdbURL: string = BITDB_URL) { | ||
this.bitdbURL = bitdbURL | ||
} | ||
|
||
public async get(query: QueryInterface): Promise<BitDBResponse> { | ||
try { | ||
const s: string = JSON.stringify(query) | ||
const b64: string = Buffer.from(s).toString("base64") | ||
const url: string = `${this.bitdbURL}q/${b64}` | ||
const tokenRes: AxiosResponse = await axios.get(url) | ||
return tokenRes.data | ||
} catch (error) { | ||
if (error.response && error.response.data) throw error.response.data | ||
else throw error | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
export interface IConfig { | ||
restURL?: string | ||
wsURL?: string | ||
bitdbURL?: string | ||
} | ||
|
||
export interface SocketConfig { | ||
restURL?: string | ||
wsURL?: string | ||
callback?: Function | ||
} | ||
|
||
export interface QueryInterface { | ||
amount?: number | ||
label?: string | ||
message?: string | ||
} | ||
|
||
export interface BitDBResponse { | ||
message: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters