/**
 * `GET /api/v1/satellites` — the catalogue, for everybody, everywhere.
 *
 * The one route here that takes no query at all, and the absence is the design
 * rather than an omission. `/flights` and `/weather` both resolve a region
 * because their answers are local; a satellite catalogue is not. See the note at
 * the top of `satellites/index.ts` for the reasoning, and note the consequence:
 * with no parameter there is no key space, so none of the amplification concerns
 * that shape `regions.ts` apply. There is exactly one body and it is the same one
 * for every caller.
 *
 * Publicly cacheable, for a TTL measured in hours. Orbital elements for objects
 * broadcasting their position to anyone with a radio are not personal data, and
 * this body does not vary by who asked.
 */

import type { FastifyInstance } from "fastify";
import { publicCache } from "../cache.ts";
import type { Services } from "../services.ts";

export function registerSatellites(app: FastifyInstance, services: Services): void {
  app.get("/api/v1/satellites", async (req, reply) => {
    const body = await services.satellites.current();
    publicCache(req, reply, body.ttlSeconds);
    return body;
  });
}
