A simple React app that downloads currency data from the Czech National Bank and allows to convert from/to Czech crowns (CZK).
- Install the dependencies with
npm install
- Start the development server by running
npm start
. - That's it!
- React Components tests:
npm test
- Browser tests in Playwright:
npx playwright test
- React.js + TypeScript
- React Hooks
- React Query with the
query-sync-storage-persister
plugin - React Styled Components with Tailwind CSS
- API endpoint: https://www.cnb.cz/en/financial-markets/foreign-exchange-market/central-bank-exchange-rate-fixing/central-bank-exchange-rate-fixing/daily.txt
- Documentation: https://www.cnb.cz/en/faq/Format-of-the-foreign-exchange-market-rates/
Due to the fact that CNB API does not follow best practices for CORS settings on the server, I use a custom CORS proxy run as a Cloudflare Worker. Free online proxies work only from localhost or are highly unstable.
All API calls are proxied through this server.
App is designed in a way so it's doesn't call the API unnecessarily often. It uses caching into browser's localStorage
as well as doesn't call the API after today's data are already fetched. If it's a weekend, it waits until Monday for a refetch. However, the solution is not 100% reliable as the React Query sometimes make a refetch anyway.