Skip to content

fix(currency): correct jsDelivr npm scope - #699

Open
cahthuranag wants to merge 3 commits into
d8a-tech:masterfrom
cahthuranag:feat/currency-api-fallback
Open

cahthuranag wants to merge 3 commits into
d8a-tech:masterfrom
cahthuranag:feat/currency-api-fallback

Conversation

@cahthuranag

@cahthuranag cahthuranag commented Nov 2, 2026 •

Copy link
Copy Markdown

pkg/currency/fwa.go builds the primary URL with the npm scope @FWA0:

https://cdn.jsdelivr.net/npm/@FWA0/currency-api@latest/v1/currencies/usd.json  -> 404
https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json  -> 200

So every refresh fails on jsDelivr and falls through to latest.currency-api.pages.dev.

Changes:

  • jsDelivrBase now uses @fawazahmed0/currency-api.
  • Tests: a case for both endpoints failing in TestAPIDownloader_Download_ArrayDriven, and TestAPIDownloader_FetchRates_TriesEndpointsInOrder, which runs against an httptest server and checks the exact URL order.

Testing: go vet ./pkg/currency/ and go test ./pkg/currency/ pass. I did not run golangci-lint locally.

Disclosure: I work on allratestoday.com.

The primary URL used the @Fwa0 npm scope, which does not exist on
jsDelivr (HTTP 404), so every refresh fell through to pages.dev and
there was no fallback left if pages.dev failed.

- jsDelivr base now uses @fawazahmed0/currency-api
- add a third URL with the same JSON shape after pages.dev
- tests: third-endpoint fallback, all-endpoints-fail, and request order

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

analyticsmessiah-cpu commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks @cahthuranag, great catch. The @FWA0 scope has been 404ing on every refresh, and the tests are exactly what we'd want.

We'd rather keep third-party hosts out of the default chain, since self-hosted users in regulated setups review every outbound host. So we opened #700, which adds a currency.extra_source_urls setting. Anyone who wants AllRatesToday as a fallback can point it at https://allratestoday.com/api/compat/currency-api/latest/v1/currencies.

Edit: an earlier version of this comment said #700 would include a docs page using AllRatesToday as the worked example, credited to your team. That page was dropped in review in favor of the flag's own documentation, so the docs won't mention AllRatesToday. Sorry for overpromising.

Could you trim this PR to the jsDelivrBase fix plus the ordering tests (dropping the hardcoded third URL)? Then we'll merge both. Review on #700 is welcome too.

And if d8a is useful to you, a ⭐ on the repo helps a lot. Thanks again!


Generated by Claude Code

Keep third-party hosts out of the default chain; d8a-tech#700 adds a setting for
extra sources instead. This leaves the jsDelivr scope fix and the
endpoint-order test.
@cahthuranag

Copy link
Copy Markdown
Author

Trimmed: third URL removed, this is now the jsDelivrBase fix plus the ordering tests. Title and description updated.

@cahthuranag cahthuranag changed the title fix(currency): correct jsDelivr npm scope and add a third fallback URL fix(currency): correct jsDelivr npm scope Nov 4, 2026
archbottle pushed a commit that referenced this pull request Nov 6, 2026
* feat(currency): configurable extra rate sources + docs

Add currency.extra_source_urls (CURRENCY_EXTRA_SOURCE_URLS,
--currency-extra-source-urls): base URLs tried in order after the
built-in jsDelivr and pages.dev mirrors. Empty by default, so no new
outbound hosts unless configured.

- WithExtraSourceURLs option on the FWA converter
- test: extra sources tried after mirrors, in order, whitespace and
  trailing slashes trimmed
- docs: Currency rate sources page with an AllRatesToday example

Context: #699

* fix(currency): address review on extra rate sources

- Drop the currency-rate-sources docs page; the flag usage text documents the option.
- Preallocate the URL slice in fetchRates (prealloc).
- Wrap a long line in the extra-sources test (lll).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmmPjtm4mM9UzJov5Q6pE3

---------

Co-authored-by: d8a <noreply@d8a.tech>
Co-authored-by: Claude <noreply@anthropic.com>
@archbottle

Copy link
Copy Markdown
Contributor

@analyticsmessiah-cpu pong, I just merged your competing PR

@cahthuranag

Copy link
Copy Markdown
Author

@analyticsmessiah-cpu #700 is merged, but main still has the @FWA0 scope in jsDelivrBase (pkg/currency/fwa.go:26), so the primary URL still 404s. This PR is now just that one-line fix plus the ordering tests. It merges cleanly. Could you take a look?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants