feat(servers): Added new back-end servers

This commit is contained in:
Daniel Gonzalez
2025-01-21 12:40:36 -04:00
parent 3700401a30
commit 93bf2c8696
3 changed files with 11 additions and 31 deletions
+2 -12
View File
@@ -16,16 +16,6 @@ import Footer from './components/footer'
import NavMenu from './components/nav-menu'
import AppBody from './components/app-body'
// Default alternative servers.
const defaultServerOptions = [
{ value: 'https://free-bch.fullstack.cash', label: 'https://free-bch.fullstack.cash' },
{ value: 'https://bc01-ca-bch-consumer.fullstackcash.nl', label: 'https://bc01-ca-bch-consumer.fullstackcash.nl' },
{ value: 'https://pdx01-usa-bch-consumer.fullstackcash.nl', label: 'https://pdx01-usa-bch-consumer.fullstackcash.nl' },
{ value: 'https://wa-usa-bch-consumer.fullstackcash.nl', label: 'https://wa-usa-bch-consumer.fullstackcash.nl' }
]
// let _this
function App (props) {
// BEGIN STATE
@@ -38,7 +28,7 @@ function App (props) {
const [menuState, setMenuState] = useState(0)
const [wallet, setWallet] = useState(false)
const [servers, setServers] = useState(defaultServerOptions)
const [servers, setServers] = useState([])
// Startup state
// When the page is loaded, it goes through a series of async network calls
@@ -52,7 +42,7 @@ function App (props) {
const [showStartModal, setShowStartModal] = useState(true)
const [modalBody, setModalBody] = useState([])
const [hideSpinner, setHideSpinner] = useState(false)
const [denyClose, setDenyClose] = useState(false)
const [denyClose, setDenyClose] = useState(false) // Deny modal to be closed
// Load all the app state into a single object that can be passed to child
// components.
+3 -10
View File
@@ -92,22 +92,15 @@ class AsyncLoad {
const gistLib = new GistServers()
const gistServers = await gistLib.getServerList()
const serversAry = []
for (let i = 0; i < gistServers.length; i++) {
serversAry.push({ value: gistServers[i].url, label: gistServers[i].url })
}
return serversAry
return gistServers
} catch (err) {
console.error('Error trying to retrieve list of servers from GitHub: ', err)
console.log('Returning hard-coded list of servers.')
const defaultOptions = [
{ value: 'https://free-bch.fullstack.cash', label: 'https://free-bch.fullstack.cash' },
{ value: 'https://bc01-ca-bch-consumer.fullstackcash.nl', label: 'https://bc01-ca-bch-consumer.fullstackcash.nl' },
{ value: 'https://pdx01-usa-bch-consumer.fullstackcash.nl', label: 'https://pdx01-usa-bch-consumer.fullstackcash.nl' },
{ value: 'https://wa-usa-bch-consumer.fullstackcash.nl', label: 'https://wa-usa-bch-consumer.fullstackcash.nl' }
{ value: 'https://dev-consumer.psfoundation.info', label: 'https://dev-consumer.psfoundation.info' }
]
return defaultOptions
+6 -9
View File
@@ -13,22 +13,19 @@ class GistServers {
async getServerList () {
try {
// https://gist.github.com/christroutner/e818ecdaed6c35075bfc0751bf222258
const gistUrl =
'https://api.github.com/gists/63c5513782181f8b8ea3eb89f7cadeb6'
// 'https://api.github.com/gists/63c5513782181f8b8ea3eb89f7cadeb6'
const gistUrl = 'https://consumers.psfoundation.info/consumers.json'
// Retrieve the gist from github.com.
const result = await this.axios.get(gistUrl)
// console.log('result.data: ', result.data)
console.log('result.data: ', result.data)
// Get the current content of the gist.
const content = result.data.files['psf-consumer-apis.json'].content
const content = result.data.servers
// console.log('content: ', content)
// Parse the JSON string into an Object.
const object = JSON.parse(content)
// console.log('object: ', object)
return object.consumerApis
return content
} catch (err) {
console.error('Error in getCRList()')
throw err