Next.js route handler serving .pmtiles from PMTILES_DIR with HTTP Range.
$ npx shadcn@latest add @highcommand/pmtiles-routeCopies the source into your project and pulls in what it needs. First time? Add the registry to components.json.
parseRange(header: string | null, size: number): { start: number; end: number; } | "invalid" | nullParses a single-range HTTP `Range` header ("bytes=0-99", "bytes=100-", "bytes=-500"). Returns null when absent or not a single bytes range (unknown units and multi-ranges are ignored, so the caller serves the full file: RFC 9110 §14.2), "invalid" when unsatisfiable.
GET(req: Request, ctx: { params: Promise<{ file: string; }>; }): Promise<Response>Serves the whole .pmtiles file, or the bytes of a `Range` request (206), from `PMTILES_DIR`; 404 for an unsafe or missing name, 416 for a bad range.
HEAD(req: Request, ctx: { params: Promise<{ file: string; }>; }): Promise<Response>Same headers as GET (size, etag, range support) with no body, for MapLibre/PMTiles size probes.