krz/moonrise

Night-sky companion for iPhone, Apple Watch and Vision Pro: what's up tonight, the Moon, planets, launches and missions, and a Library of the solar system. SwiftUI app with a Cloudflare Workers backend. astronomy cloudflare-workers ios night-sky space swiftui visionos watchos

server/README.org

v1.0.0
moonrise/server/README.org rendered · source · history · blame · raw

46 lines · 1402 bytes

moonrise-server

Cloudflare Worker: SWPC polling every 5 minutes, /v1/today, device registration, aurora pushes over APNs. D1 for storage.

local

wrangler d1 migrations apply moonrise --local
wrangler dev --test-scheduled
curl "http://localhost:8787/__scheduled?cron=*/5+*+*+*+*"
curl http://localhost:8787/v1/today

APNs cannot be reached from wrangler dev (no HTTP/2); test pushes against a deployed Worker.

deploy

Deployed 2026-10-17: https://moonrise-server.audit-labs.workers.dev (D1 moonrise 54a0c50d-2150-47ae-aa22-449e8204ad7b, APNS_KEY set).

wrangler d1 create moonrise          # put the id in wrangler.jsonc
wrangler d1 migrations apply moonrise --remote
wrangler deploy
wrangler secret put APNS_KEY < AuthKey_644XS4F2RG.p8

Launch Library 2's anonymous limit is per IP, and Workers share egress IPs, so anonymous requests from Cloudflare often get HTTP 429. With an API key:

wrangler secret put LL2_API_KEY

API

Method and path Body / result
GET /v1/today {spaceWeather: {kpNow, observedAt, kpNext24h, fetchedAt}}
POST /v1/devices {token, environment, band, utcOffsetMinutes, aurora?}; band is a 5° geomagnetic latitude band, south negative
DELETE /v1/devices/{token}
GET /healthz feed status

tests

node --test test/