give out .json and .csv, not only .ndjson

This commit is contained in:
Soph :3 2025-12-15 22:46:49 +02:00
parent 2593be8911
commit 124507d074
2 changed files with 27 additions and 1 deletions

View file

@ -1,5 +1,5 @@
import { parseHTML } from "linkedom"
import { ndjsonToJson, prettyStringify, requireBasicAuth, tripleBool, type Change, type Entry } from "./lib";
import { jsonToCsv, ndjsonToJson, prettyStringify, requireBasicAuth, tripleBool, type Change, type Entry } from "./lib";
import * as fs from "fs/promises"
import { existsSync } from "fs";
import { $ } from "bun"
@ -193,6 +193,18 @@ export class ClientResponse extends Response {
Bun.serve({
routes: {
"/": () => new ClientResponse("Sheets v2"),
"/artists.json": async () => ClientResponse.json(
ndjsonToJson((await fs.readFile("artists.ndjson")).toString("utf8"))
),
"/artists.csv": async () => new ClientResponse(
jsonToCsv(
ndjsonToJson((await fs.readFile("artists.ndjson")).toString("utf8")
)
), {
headers: {
"Content-Type": "text/csv"
}
}),
"/artists.ndjson": async () => new ClientResponse(await fs.readFile("artists.ndjson")),
"/th_artists.ndjson": async () => new ClientResponse(await fs.readFile("th_artists.ndjson")),
"/ignore-th/:id": async (req) => {