style: add eslint configuration and fixed linter issues (#35)

* style: add eslint configuration as per bee-js

* chore: add `plugin:react/reocommended` in `.eslintrc`

Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>

* chore: add `consistent` to `array-bracket-newline` as per review

* style: after automatic fixes with `npm run lint`

* style: fixed all linter errors

* refactor: fixed all linter warnings

* chore: added missing new line at end of `.prettierrc` file

Co-authored-by: nugaon <50576770+nugaon@users.noreply.github.com>
This commit is contained in:
Vojtech Simetka
2021-04-03 14:04:37 +02:00
committed by GitHub
parent 9838aa70c8
commit bc01d60728
54 changed files with 3454 additions and 2782 deletions
+97 -76
View File
@@ -1,95 +1,116 @@
import { Bee, BeeDebug, Reference } from "@ethersphere/bee-js";
import {
AllSettlements,
BalanceResponse,
Bee,
BeeDebug,
CashoutResponse,
ChequebookAddressResponse,
ChequebookBalanceResponse,
Data,
DepositTokensResponse,
FileData,
Health,
LastCashoutActionResponse,
LastChequesForPeerResponse,
LastChequesResponse,
NodeAddresses,
Peer,
PingResponse,
Reference,
Topology,
WithdrawTokensResponse,
} from '@ethersphere/bee-js'
const beeJSClient = () => {
let apiHost = process.env.REACT_APP_BEE_HOST || 'http://localhost:1633'
if (sessionStorage.getItem('api_host')) {
apiHost = String(sessionStorage.getItem('api_host'))
}
let apiHost = process.env.REACT_APP_BEE_HOST || 'http://localhost:1633'
return new Bee(apiHost)
if (sessionStorage.getItem('api_host')) {
apiHost = String(sessionStorage.getItem('api_host'))
}
return new Bee(apiHost)
}
const beeJSDebugClient = () => {
let debugApiHost = process.env.REACT_APP_BEE_DEBUG_HOST || 'http://localhost:1635'
if (sessionStorage.getItem('debug_api_host')) {
debugApiHost = String(sessionStorage.getItem('debug_api_host'))
}
let debugApiHost = process.env.REACT_APP_BEE_DEBUG_HOST || 'http://localhost:1635'
return new BeeDebug(debugApiHost)
if (sessionStorage.getItem('debug_api_host')) {
debugApiHost = String(sessionStorage.getItem('debug_api_host'))
}
return new BeeDebug(debugApiHost)
}
export const beeApi = {
status: {
health() {
return beeJSClient().isConnected()
}
status: {
health(): Promise<boolean> {
return beeJSClient().isConnected()
},
files: {
uploadFile(file: File) {
return beeJSClient().uploadFile(file)
},
downloadFile(hash: string | Reference) {
return beeJSClient().downloadFile(hash)
},
},
files: {
uploadFile(file: File): Promise<Reference> {
return beeJSClient().uploadFile(file)
},
downloadFile(hash: string | Reference): Promise<FileData<Data>> {
return beeJSClient().downloadFile(hash)
},
},
}
export const beeDebugApi = {
status: {
nodeHealth() {
return beeJSDebugClient().getHealth()
},
status: {
nodeHealth(): Promise<Health> {
return beeJSDebugClient().getHealth()
},
connectivity: {
addresses() {
return beeJSDebugClient().getNodeAddresses()
},
listPeers() {
return beeJSDebugClient().getPeers()
},
topology() {
return beeJSDebugClient().getTopology()
},
ping(peerId: string) {
return beeJSDebugClient().pingPeer(peerId)
}
},
connectivity: {
addresses(): Promise<NodeAddresses> {
return beeJSDebugClient().getNodeAddresses()
},
balance: {
balances() {
return beeJSDebugClient().getAllBalances()
}
listPeers(): Promise<Peer[]> {
return beeJSDebugClient().getPeers()
},
chequebook: {
address() {
return beeJSDebugClient().getChequebookAddress()
},
balance() {
return beeJSDebugClient().getChequebookBalance()
},
getLastCheques() {
return beeJSDebugClient().getLastCheques()
},
peerCashout(peerId: string) {
return beeJSDebugClient().cashoutLastCheque(peerId)
},
getPeerLastCashout(peerId: string) {
return beeJSDebugClient().getLastCashoutAction(peerId)
},
getPeerLastCheques(peerId: string) {
return beeJSDebugClient().getLastChequesForPeer(peerId)
},
withdraw(amount: bigint) {
return beeJSDebugClient().withdrawTokens(amount)
},
deposit(amount: bigint) {
return beeJSDebugClient().depositTokens(amount)
},
topology(): Promise<Topology> {
return beeJSDebugClient().getTopology()
},
settlements: {
getSettlements() {
return beeJSDebugClient().getAllSettlements()
}
}
}
ping(peerId: string): Promise<PingResponse> {
return beeJSDebugClient().pingPeer(peerId)
},
},
balance: {
balances(): Promise<BalanceResponse> {
return beeJSDebugClient().getAllBalances()
},
},
chequebook: {
address(): Promise<ChequebookAddressResponse> {
return beeJSDebugClient().getChequebookAddress()
},
balance(): Promise<ChequebookBalanceResponse> {
return beeJSDebugClient().getChequebookBalance()
},
getLastCheques(): Promise<LastChequesResponse> {
return beeJSDebugClient().getLastCheques()
},
peerCashout(peerId: string): Promise<CashoutResponse> {
return beeJSDebugClient().cashoutLastCheque(peerId)
},
getPeerLastCashout(peerId: string): Promise<LastCashoutActionResponse> {
return beeJSDebugClient().getLastCashoutAction(peerId)
},
getPeerLastCheques(peerId: string): Promise<LastChequesForPeerResponse> {
return beeJSDebugClient().getLastChequesForPeer(peerId)
},
withdraw(amount: bigint): Promise<WithdrawTokensResponse> {
return beeJSDebugClient().withdrawTokens(amount)
},
deposit(amount: bigint): Promise<DepositTokensResponse> {
return beeJSDebugClient().depositTokens(amount)
},
},
settlements: {
getSettlements(): Promise<AllSettlements> {
return beeJSDebugClient().getAllSettlements()
},
},
}