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

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

46 lines · 1402 bytes

4 symbols in this file
 1#+title: moonrise-server
 2
 3Cloudflare Worker: SWPC polling every 5 minutes, =/v1/today=, device
 4registration, aurora pushes over APNs. D1 for storage.
 5
 6* local
 7#+begin_src sh
 8wrangler d1 migrations apply moonrise --local
 9wrangler dev --test-scheduled
10curl "http://localhost:8787/__scheduled?cron=*/5+*+*+*+*"
11curl http://localhost:8787/v1/today
12#+end_src
13
14APNs cannot be reached from =wrangler dev= (no HTTP/2); test pushes
15against a deployed Worker.
16
17* deploy
18Deployed 2026-10-17: https://moonrise-server.audit-labs.workers.dev
19(D1 =moonrise= 54a0c50d-2150-47ae-aa22-449e8204ad7b, APNS_KEY set).
20
21#+begin_src sh
22wrangler d1 create moonrise          # put the id in wrangler.jsonc
23wrangler d1 migrations apply moonrise --remote
24wrangler deploy
25wrangler secret put APNS_KEY < AuthKey_644XS4F2RG.p8
26#+end_src
27
28Launch Library 2's anonymous limit is per IP, and Workers share egress IPs,
29so anonymous requests from Cloudflare often get HTTP 429. With an API key:
30
31#+begin_src sh
32wrangler secret put LL2_API_KEY
33#+end_src
34
35* API
36| Method and path | Body / result |
37|-
38| =GET /v1/today= | ={spaceWeather: {kpNow, observedAt, kpNext24h, fetchedAt}}= |
39| =POST /v1/devices= | ={token, environment, band, utcOffsetMinutes, aurora?}=; band is a 5° geomagnetic latitude band, south negative |
40| =DELETE /v1/devices/{token}= | |
41| =GET /healthz= | feed status |
42
43* tests
44#+begin_src sh
45node --test test/
46#+end_src