mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
feat(REST URL): removing default REST URL anti-pattern. Error thrown if URL is not specified at startup
This commit is contained in:
+1
-1
@@ -10,7 +10,7 @@
|
||||
],
|
||||
"main": "src/bch-js.js",
|
||||
"scripts": {
|
||||
"test": "c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
||||
"test": "export RESTURL=http://localhost:5942/v6/ && c8 mocha --trace-warnings --unhandled-rejections=strict --timeout 30000 test/unit/",
|
||||
"test:integration": "npm run test:integration:local:noauth",
|
||||
"test:integration:nft": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 -g '#nft1' test/integration/slp.js",
|
||||
"test:integration:bchn": "export RESTURL=https://bchn.fullstack.cash/v6/ && export IS_USING_FREE_TIER=true && mocha --timeout 30000 test/integration/",
|
||||
|
||||
+5
-2
@@ -45,7 +45,6 @@ import Ecash from './ecash.js'
|
||||
// Indexers
|
||||
import Electrumx from './electrumx.js'
|
||||
import PsfSlpIndexer from './psf-slp-indexer.js'
|
||||
const DEFAULT_REST_API = 'https://api.fullstack.cash/v6/'
|
||||
|
||||
class BCHJS {
|
||||
constructor (config) {
|
||||
@@ -54,7 +53,11 @@ class BCHJS {
|
||||
this.restURL = config.restURL
|
||||
} else if (process.env.RESTURL && process.env.RESTURL !== '') {
|
||||
this.restURL = process.env.RESTURL
|
||||
} else this.restURL = DEFAULT_REST_API
|
||||
} else {
|
||||
throw new Error(
|
||||
'REST API URL is required. Provide config.restURL or set the RESTURL environment variable.'
|
||||
)
|
||||
}
|
||||
|
||||
// Retrieve the Bearer token for simple token authentication.
|
||||
this.bearerToken = '' // default value.
|
||||
|
||||
@@ -534,6 +534,8 @@ class ElectrumX {
|
||||
*/
|
||||
async txData (txid) {
|
||||
try {
|
||||
console.log('bch-js txData() restURL: ', this.restURL)
|
||||
|
||||
// Handle single transaction.
|
||||
if (typeof txid === 'string') {
|
||||
const response = await this.axios.get(
|
||||
|
||||
Reference in New Issue
Block a user