Skip to content

Commit

Permalink
front: use report.json
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta committed Aug 28, 2023
1 parent 6de50bc commit 90535b1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 89 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ View the Public Gateway Checker in action

## Adding a new public gateway

If you'd like to add a new public gateway, please edit `./src/gateways.ts`:
If you'd like to add a new public gateway, please edit `./gateways.yml`:

1. Add the gateway's address to the bottom of the list
2. Make sure the final item in the list does **not** have a comma at the end, but all preceding items do
Expand Down
2 changes: 1 addition & 1 deletion src/Cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Cors extends CheckBase implements Checkable {

async check (): Promise<void> {
const now = Date.now()
const gatewayAndHash = this.parent.gateway.replace(':hash', HASH_TO_TEST)
const gatewayAndHash = `${this.parent.gateway}/ipfs/${HASH_TO_TEST}`
const testUrl = `${gatewayAndHash}?now=${now}#x-ipfs-companion-no-redirect`
// response body can be accessed only if fetch was executed when
// liberal CORS is present (eg. '*')
Expand Down
2 changes: 1 addition & 1 deletion src/GatewayNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GatewayNode extends UiComponent /* implements Checkable */ {
this.tag.append(this.trustless.tag)

this.link = document.createElement('div')
const gatewayAndHash = gateway.replace(':hash', HASH_TO_TEST)
const gatewayAndHash = `${gateway}/ipfs/${HASH_TO_TEST}`
this.link.url = new URL(gatewayAndHash)
this.link.textContent = gatewayHostname(this.link.url)
this.link.className = 'Link'
Expand Down
2 changes: 1 addition & 1 deletion src/Trustless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Trustless extends CheckBase implements Checkable {

async check (): Promise<void> {
const now = Date.now()
const gatewayAndHash = this.parent.gateway.replace(':hash', HASH_TO_TEST)
const gatewayAndHash = `${this.parent.gateway}/ipfs/${HASH_TO_TEST}`
this.parent.tag.classList.add('trustless')
try {
const trustlessResponseTypesTests = await Promise.all(TRUSTLESS_RESPONSE_TYPES.map(
Expand Down
83 changes: 0 additions & 83 deletions src/gateways.ts

This file was deleted.

4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Workbox } from 'workbox-window'
import { Checker } from './Checker'
import { Log } from './Log'
import gateways from './gateways'
import { loadCountly } from './metrics'
import report from './report.json'

const wb = new Workbox('/sw.js')
void wb.register()
Expand All @@ -12,6 +12,8 @@ const log = new Log('App index')

window.checker = new Checker()

const gateways = Object.keys(report)

window.checker.checkGateways(gateways).catch((err) => {
log.error('Unexpected error')
log.error(err)
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "aegir/src/config/tsconfig.aegir.json",
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true,
"outDir": "dist",
"paths": {
"*": [
Expand All @@ -12,6 +14,6 @@
"types",
"test", // remove this line if you don't want to type-check tests
"src",
"src/gateways.ts"
"src/report.json"
]
}

0 comments on commit 90535b1

Please sign in to comment.