Pinned 2026 toolchains (Go 1.26, Rust 1.98/edition 2024, Python 3.14 + uv, Node 24, Zig 0.16, NixOS 26.05), postgres 18 / mongo 8, lockfiles built from, non-root runtimes, .dockerignore, per-project LICENSE, READMEs with the git.devai.io clone line, checkout@v7 CI. Security fixes in the legacy Rust APIs (any-password login, self-assigned admin, hard-coded JWT secret), JWT alg/exp/sub enforcement across the blog series, safe markdown links in the frontends, and many smaller bugs — every project was built, run and exercised end to end. Adds scripts/publish.sh + a CI publish job that splits every folder into its own repo at git.devai.io/templates/<folder>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01128fhuZbgivaSJvtMf4s1G
65 lines
2.2 KiB
Markdown
65 lines
2.2 KiB
Markdown
# crypto-ticker
|
|
|
|
A little price board for Bitcoin, Ethereum and friends that refreshes itself
|
|
every 30 seconds, with 24-hour changes in green and red. It teaches polling:
|
|
asking an API again on a timer.
|
|
|
|
## Run
|
|
|
|
Get it: `git clone https://git.devai.io/templates/crypto-ticker.git`
|
|
|
|
Double-click `index.html` — it opens in your browser and works, as long as
|
|
you're online (it calls the price API live). Nothing to install.
|
|
|
|
Or serve it like production:
|
|
|
|
```sh
|
|
docker compose up --build
|
|
```
|
|
|
|
Then open http://localhost:8080.
|
|
|
|
## How it works
|
|
|
|
The API can't tell the page when prices change, so the page asks again on a
|
|
timer:
|
|
|
|
```js
|
|
refresh(); // once now…
|
|
setInterval(refresh, 30000); // …then every 30 seconds
|
|
```
|
|
|
|
Each `refresh()` is one ordinary `fetch()` to CoinGecko's free
|
|
`/simple/price` endpoint (no key needed) with the coin ids in the query string
|
|
and `include_24hr_change=true`. `render()` rebuilds one row per coin with
|
|
`createElement` and `textContent`, formats prices with `Intl.NumberFormat`
|
|
(extra decimals for coins under $1), and colors the change green `▲` or red
|
|
`▼`.
|
|
|
|
Polling a free API means you will sometimes be throttled. On a 429 ("too many
|
|
requests") or a network error, the page keeps the last good prices on screen,
|
|
says so, and simply tries again on the next tick. "Loading prices…" shows until
|
|
the first answer arrives.
|
|
|
|
Try it: add a coin to `COINS` (e.g. `cardano`), poll every 60 seconds to be
|
|
gentler on the free tier, or add `include_market_cap=true` and show it.
|
|
|
|
## Layout
|
|
|
|
```
|
|
index.html an empty rows box, a status line and "last updated"
|
|
app.js COINS, refresh(), render() and the interval
|
|
styles.css the look — green / red change colors; follows light or dark mode
|
|
```
|
|
|
|
## Deploy
|
|
|
|
Push to your own GitHub repo and the shipped workflow
|
|
(`.github/workflows/ci.yml`) tests the compose stack, publishes the image to
|
|
GHCR, and — once you set the `DEPLOY_HOST` / `DEPLOY_USER` variables and
|
|
`DEPLOY_KEY` secret — deploys it to your server over ssh.
|
|
|
|
---
|
|
Part of [devai.io](https://devai.io) — the APIs & Data track: fetch real data
|
|
from the internet. Next up:
|
|
[dictionary-lookup](https://git.devai.io/templates/dictionary-lookup).
|