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

Commit a1c0bd8138

a1c0bd81382e413f2c7549ebe65c94977655398a

parent: c5f57d4e01

Unsigned

cmc <hello@cleberg.net> · 2026-10-23 06:54 UTC

Space Devs terms: hourly SNAPI poll, linked credits (!149)

- Poll the Spaceflight News API at the top of each hour, as The Space Devs asked; the 10-minute cron still sends digests.
- Credits rows for Launch Library 2 and the Spaceflight News API link to thespacedevs.com.
- App Store description gains a DATA section crediting both (3,761 of 4,000 characters).

Server tests 84/84; app builds for the simulator.

Layout: unified · split

App/AppStore/metadata.md +3
@@ -60,6 +60,9 @@ AND MORE
6060- Control Center controls for the Sky, Sun and Launches tabs
6161- An Apple Watch app and complications
6262
63DATA
64Launch data from Launch Library 2 and news headlines from the Spaceflight News API, both by The Space Devs (thespacedevs.com).
65
6366## Keywords
6467
6568astronomy,stars,planets,moon phase,constellations,star chart,stargazing,nasa,launch,aurora,eclipse
App/Sources/SettingsScreen.swift +6 −3
@@ -259,6 +259,7 @@ struct CreditsScreen: View {
259259 private struct Credit: Hashable {
260260 var name: String
261261 var detail: String
262 var url: URL? = nil
262263 }
263264
264265 private let software: [Credit] = [
@@ -273,11 +274,11 @@ struct CreditsScreen: View {
273274 private let feeds: [Credit] = [
274275 Credit(name: "Space weather and aurora forecast", detail: "NOAA Space Weather Prediction Center."),
275276 Credit(name: "Images of the Sun", detail: "Courtesy of NASA/SDO and the AIA, EVE, and HMI science teams."),
276 Credit(name: "Launch schedule", detail: "The Space Devs, Launch Library 2."),
277 Credit(name: "Launch schedule", detail: "The Space Devs, Launch Library 2.", url: URL(string: "https://thespacedevs.com")),
277278 Credit(name: "Deep Space Network status", detail: "NASA/JPL, DSN Now."),
278279 Credit(name: "Satellite orbits", detail: "CelesTrak."),
279280 Credit(name: "Mars rover raw images", detail: "NASA/JPL-Caltech, with MSSS and ASU for some cameras."),
280 Credit(name: "Space news headlines", detail: "Spaceflight News API, The Space Devs. Articles belong to their publishers."),
281 Credit(name: "Space news headlines", detail: "Spaceflight News API, The Space Devs. Articles belong to their publishers.", url: URL(string: "https://thespacedevs.com")),
281282 ]
282283
283284 /// Every distinct image credit used by the Library, grouped by licence.
@@ -320,11 +321,13 @@ struct CreditsScreen: View {
320321 .navigationTitle("Credits and licences")
321322 }
322323
324 @ViewBuilder
323325 private func row(_ c: Credit) -> some View {
324 VStack(alignment: .leading, spacing: 2) {
326 let text = VStack(alignment: .leading, spacing: 2) {
325327 Text(c.name)
326328 Text(c.detail).font(.footnote).foregroundStyle(.secondary)
327329 }
330 if let url = c.url { Link(destination: url) { text } } else { text }
328331 }
329332}
330333
server/src/index.ts +2 −2
@@ -210,7 +210,7 @@ export default {
210210 async scheduled(controller: ScheduledController, env: Env, ctx: ExecutionContext): Promise<void> {
211211 const now = new Date(controller.scheduledTime);
212212 if (controller.cron === NEWS_CRON) {
213 ctx.waitUntil(pollNews(env, now).then(() => sendNewsDigests(env, now)));
213 ctx.waitUntil((now.getUTCMinutes() === 0 ? pollNews(env, now) : Promise.resolve()).then(() => sendNewsDigests(env, now)));
214214 if (now.getUTCHours() === 0 && now.getUTCMinutes() === 0) ctx.waitUntil(prune(env, now));
215215 } else if (controller.cron === SATELLITE_CRON) ctx.waitUntil(pollSatellites(env, now));
216216 else if (controller.cron === FOCUS_CRON) ctx.waitUntil(focusTick(env, now));
@@ -760,7 +760,7 @@ async function sendAuroraAlerts(env: Env, w: SpaceWeather, wind: SolarWind | nul
760760 }));
761761}
762762
763/** Spaceflight News API every 10 minutes, matching its cache lifetime; the last good copy is kept on failure. */
763/** Spaceflight News API hourly, as The Space Devs asked; the last good copy is kept on failure. */
764764async function pollNews(env: Env, now: Date): Promise<void> {
765765 try {
766766 const articles = await fetchLatest();
server/src/news.ts +1 −1
@@ -1,4 +1,4 @@
1// Spaceflight News API (The Space Devs). Free, no key. Polled every 10 minutes for /v1/news and the daily digest push.
1// Spaceflight News API (The Space Devs). Free, no key. Polled hourly for /v1/news and the daily digest push.
22import { USER_AGENT } from "./agent.ts";
33
44export interface Article {
server/test/worker.test.ts +2 −2
@@ -212,7 +212,7 @@ test("an LL2 429 stops LL2 requests until /api-throttle/ says the limit has rese
212212 assert.equal(paths.length, 3);
213213});
214214
215test("/v1/news serves the articles the 10-minute cron stored", async () => {
215test("/v1/news serves the articles the hourly poll stored", async () => {
216216 const { env } = await setup({ APNS_KEY: "" });
217217 const article = { id: 7, title: "t", summary: "s", url: "https://example.com/a", image_url: null, news_site: "ESA", published_at: "2026-10-20T13:00:00Z", authors: [] };
218218 network({ "api.spaceflightnewsapi.net": () => Response.json({ results: [article] }) });
@@ -305,7 +305,7 @@ test("news digests go out in slices during the local 09:00 hour, once per local
305305 assert.equal(new Set(push.state.sent).size, PUSH_SLICE + 5);
306306 await run(env, NEWS, "2026-10-20T14:20:00Z");
307307 assert.equal(push.state.sent.length, PUSH_SLICE + 5);
308 assert.equal(snapi(), 3, "polled once per 10-minute run");
308 assert.equal(snapi(), 1, "polled at the top of the hour only");
309309 assert.equal(count(db, "SELECT count(*) AS n FROM alerts_sent WHERE kind = 'news' AND event LIKE '%:2026-10-20'"), PUSH_SLICE + 5);
310310
311311 const q = calls.find((c) => c.sql.includes("news = 1"))!;