Skip to content

Commit

Permalink
fix: reduce PR hell (#425)
Browse files Browse the repository at this point in the history
* feat: define gateways in typescript

* fix: enforce comma-dangle on multiline code

prevents PR rebase hell when users are adding more gateways

* fix: use latest gateways.json

from #419
  • Loading branch information
SgtPooki authored Jul 13, 2023
1 parent ff664d2 commit 64dce8d
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 102 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@
"env": {
"browser": true,
"node": false
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"@typescript-eslint/comma-dangle": ["error", "always-multiline"]
}
}
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Hello! To ensure this PR is correctly addressed as soon as possible by the IPFS
IF ADDING A NEW PUBLIC GATEWAY:
- Name your PR in the format `feat: add gateway.address.here`
- Make sure there is no trailing comma in the final gateway in the list at `src/gateways.json`
- Make sure there is no trailing comma in the final gateway in the list at `src/gateways.ts`
- Include a brief description of the gateway to be added (e.g. geographic location, connection speed, available space, etc)
ALL OTHER PULL REQUESTS:
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"typescript.format.semicolons": "remove",
"javascript.format.semicolons": "remove",
"typescript.suggest.includeAutomaticOptionalChainCompletions": true,
"editor.formatOnSave": false,
"editor.formatOnSave": true,
"eslint.codeActionsOnSave.rules": [],
"files.exclude": {
"package-lock.json": true
Expand All @@ -21,5 +21,9 @@
},
"[javascript]": {
"editor.defaultFormatter": "standard.vscode-standard",
},
"files.autoSave": "afterDelay",
"editor.codeActionsOnSave": {
"source.fixAll": true
}
}
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.json`:
If you'd like to add a new public gateway, please edit `./src/gateways.ts`:

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
6 changes: 3 additions & 3 deletions src/Flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Flag extends UiComponent {
if (tokenAvailable) {
return `https://cloudflare-dns.com/dns-query?name=${this.hostname}&type=A`
}
})
}),
])
if (url == null) {
// No available tokens...
Expand All @@ -83,8 +83,8 @@ class Flag extends UiComponent {
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/dns-json'
}
Accept: 'application/dns-json',
},
})
const responseJson = await response.json()

Expand Down
2 changes: 1 addition & 1 deletion src/GatewayNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GatewayNode extends UiComponent /* implements Checkable */ {
this.ipns.check().then(() => { log.debug(this.gateway, 'IPNS success') }).then(this.onSuccessfulCheck.bind(this)),
this.origin.check().then(() => { log.debug(this.gateway, 'Origin success') }).then(this.onSuccessfulCheck.bind(this)),
this.trustless.check().then(
() => { log.debug(this.gateway, 'Trustless success') }).then(this.onSuccessfulCheck.bind(this))
() => { log.debug(this.gateway, 'Trustless success') }).then(this.onSuccessfulCheck.bind(this)),
]

// we care only about the fastest method to return a success
Expand Down
2 changes: 1 addition & 1 deletion src/Trustless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Trustless extends CheckBase implements Checkable {
const testUrl = `${gatewayAndHash}?format=${trustlessTypes}&now=${now}#x-ipfs-companion-no-redirect`
const response = await fetch(testUrl)
return Boolean(response.headers.get('Content-Type')?.includes(`application/vnd.ipld.${trustlessTypes}`))
}
},
))

const failedTests = TRUSTLESS_RESPONSE_TYPES.filter((_result, idx) => !trustlessResponseTypesTests[idx])
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export {
// IFRAME_HASH,
IMG_HASH,
IPNS_PATH_TO_TEST,
TRUSTLESS_RESPONSE_TYPES
TRUSTLESS_RESPONSE_TYPES,
}
87 changes: 0 additions & 87 deletions src/gateways.json

This file was deleted.

87 changes: 87 additions & 0 deletions src/gateways.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
export default [
'https://ipfs.io/ipfs/:hash',
'https://dweb.link/ipfs/:hash',
'https://gateway.ipfs.io/ipfs/:hash',
'https://ninetailed.ninja/ipfs/:hash',
'https://via0.com/ipfs/:hash',
'https://ipfs.eternum.io/ipfs/:hash',
'https://hardbin.com/ipfs/:hash',
'https://cloudflare-ipfs.com/ipfs/:hash',
'https://astyanax.io/ipfs/:hash',
'https://cf-ipfs.com/ipfs/:hash',
'https://ipns.co/ipfs/:hash',
'https://gateway.originprotocol.com/ipfs/:hash',
'https://gateway.pinata.cloud/ipfs/:hash',
'https://ipfs.sloppyta.co/ipfs/:hash',
'https://ipfs.busy.org/ipfs/:hash',
'https://ipfs.greyh.at/ipfs/:hash',
'https://gateway.serph.network/ipfs/:hash',
'https://gw3.io/ipfs/:hash',
'https://jorropo.net/ipfs/:hash',
'https://ipfs.fooock.com/ipfs/:hash',
'https://cdn.cwinfo.net/ipfs/:hash',
'https://aragon.ventures/ipfs/:hash',
'https://permaweb.io/ipfs/:hash',
'https://ipfs.best-practice.se/ipfs/:hash',
'https://storjipfs-gateway.com/ipfs/:hash',
'https://ipfs.runfission.com/ipfs/:hash',
'https://ipfs.trusti.id/ipfs/:hash',
'https://ipfs.overpi.com/ipfs/:hash',
'https://ipfs.ink/ipfs/:hash',
'https://ipfsgateway.makersplace.com/ipfs/:hash',
'https://ipfs.funnychain.co/ipfs/:hash',
'https://ipfs.telos.miami/ipfs/:hash',
'https://ipfs.mttk.net/ipfs/:hash',
'https://ipfs.fleek.co/ipfs/:hash',
'https://ipfs.jbb.one/ipfs/:hash',
'https://ipfs.yt/ipfs/:hash',
'https://hashnews.k1ic.com/ipfs/:hash',
'https://ipfs.drink.cafe/ipfs/:hash',
'https://ipfs.kavin.rocks/ipfs/:hash',
'https://ipfs.denarius.io/ipfs/:hash',
'https://crustwebsites.net/ipfs/:hash',
'https://ipfs0.sjc.cloudsigma.com/ipfs/:hash',
'http://ipfs.genenetwork.org/ipfs/:hash',
'https://ipfs.eth.aragon.network/ipfs/:hash',
'https://ipfs.smartholdem.io/ipfs/:hash',
'https://ipfs.xoqq.ch/ipfs/:hash',
'http://natoboram.mynetgear.com:8080/ipfs/:hash',
'https://video.oneloveipfs.com/ipfs/:hash',
'http://ipfs.anonymize.com/ipfs/:hash',
'https://ipfs.scalaproject.io/ipfs/:hash',
'https://search.ipfsgate.com/ipfs/:hash',
'https://ipfs.decoo.io/ipfs/:hash',
'https://alexdav.id/ipfs/:hash',
'https://ipfs.uploads.nu/ipfs/:hash',
'https://hub.textile.io/ipfs/:hash',
'https://ipfs1.pixura.io/ipfs/:hash',
'https://ravencoinipfs-gateway.com/ipfs/:hash',
'https://konubinix.eu/ipfs/:hash',
'https://ipfs.tubby.cloud/ipfs/:hash',
'https://ipfs.lain.la/ipfs/:hash',
'https://ipfs.kaleido.art/ipfs/:hash',
'https://ipfs.slang.cx/ipfs/:hash',
'https://ipfs.arching-kaos.com/ipfs/:hash',
'https://storry.tv/ipfs/:hash',
'https://ipfs.1-2.dev/ipfs/:hash',
'https://dweb.eu.org/ipfs/:hash',
'https://permaweb.eu.org/ipfs/:hash',
'https://ipfs.namebase.io/ipfs/:hash',
'https://ipfs.tribecap.co/ipfs/:hash',
'https://ipfs.kinematiks.com/ipfs/:hash',
'https://nftstorage.link/ipfs/:hash',
'https://gravity.jup.io/ipfs/:hash',
'http://fzdqwfb5ml56oadins5jpuhe6ki6bk33umri35p5kt2tue4fpws5efid.onion/ipfs/:hash',
'https://tth-ipfs.com/ipfs/:hash',
'https://ipfs.chisdealhd.co.uk/ipfs/:hash',
'https://ipfs.alloyxuast.tk/ipfs/:hash',
'https://4everland.io/ipfs/:hash',
'https://ipfs-gateway.cloud/ipfs/:hash',
'https://w3s.link/ipfs/:hash',
'https://cthd.icu/ipfs/:hash',
'https://ipfs.tayfundogdas.me/ipfs/:hash',
'https://ipfs.jpu.jp/ipfs/:hash',
'https://ipfs.soul-network.com/ipfs/:hash',
'https://ipfs.twdragon.net/ipfs/:hash',
'https://getipfs.com/ipfs/:hash',
]
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Workbox } from 'workbox-window'
import { Checker } from './Checker'
import { Log } from './Log'
import gateways from './gateways.json'
import gateways from './gateways'
import { loadCountly } from './metrics'

const wb = new Workbox('/sw.js')
Expand Down
8 changes: 4 additions & 4 deletions src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function addConsent (consent: string[]): void {
} else {
localStorage.setItem(
'metrics_consent',
JSON.stringify([consent])
JSON.stringify([consent]),
)
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ function loadCountly (): void {
Countly.init({
app_key: '3c2c0819434074fc4d339ddd8e112a1e741ecb72',
url: 'https://countly.ipfs.io',
require_consent: true // this true means consent is required
require_consent: true, // this true means consent is required
})
/**
* @see https://support.count.ly/hc/en-us/articles/360037441932-Web-analytics-JavaScript-#features-for-consent
Expand All @@ -99,13 +99,13 @@ function loadCountly (): void {
...performanceFeatures,
...uxFeatures,
...feedbackFeatures,
...locationFeatures
...locationFeatures,
],
minimal: minimalFeatures,
performance: performanceFeatures,
ux: uxFeatures,
feedback: feedbackFeatures,
location: locationFeatures
location: locationFeatures,
})

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"types",
"test", // remove this line if you don't want to type-check tests
"src",
"src/gateways.json"
"src/gateways.ts"
]
}

0 comments on commit 64dce8d

Please sign in to comment.