A simple map visualization app built with Astro, Preact, and MapLibre GL JS. Upon visiting the site, location data is extracted from the Cloudflare request headers and stored in a SQLite database.
- Create a new Cloudflare D1 database.
- Update the variables in
wrangler.toml
to match your database under[[d1_databases]]
. - Create a
.dev.vars
and.env
files based on.dev.vars.example
and.env.example
and setCLOUDFLARE_ACCOUNT_ID
,CLOUDFLARE_DATABASE_ID
,CLOUDFLARE_D1_TOKEN
(you can refer this doc on how to create D1 specific token) andCLOUDFLARE_D1_BINDING
environment variables. - Ensure you're on Node.js 20.17.0 and pnpm 9.9.0.
- Run
pnpm install
to install the dependencies. - Run
pnpm db:generate
to generate the database migrations. - Run
pnpm db:migrate
to apply the migrations. - Run
pnpm dev:all
to start the development server and the database studio. - To actually log the coordinates, you'll have to use Cloudflare Tunnel to proxy the development server, else 0, 0 would be logged.
- Just install
cloudflared
and runcloudflared tunnel --url http://localhost:4321
(or the port your dev server is running on) to get a URL to visit.