Initial commit

This commit is contained in:
admin
2026-05-26 22:46:00 +02:00
commit 7e2c2ff89c
256 changed files with 51523 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import { NextRequest, NextResponse } from "next/server";
import { rawDb } from "@/lib/db/client";
import { assertLocalRequest } from "@/lib/api/localOnly";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
const TABLES = [
"images",
"studios",
"labels",
"series",
"actresses",
"genres",
"tag_categories",
"tags",
"collections",
"image_actresses",
"image_genres",
"image_tags",
"collection_images",
"actress_categories",
"actress_categories_map",
"app_settings",
];
export async function GET(req: NextRequest) {
const blocked = assertLocalRequest(req);
if (blocked) return blocked;
const data: Record<string, unknown[]> = {};
for (const t of TABLES) {
try {
data[t] = rawDb.prepare(`SELECT * FROM ${t}`).all();
} catch {
data[t] = [];
}
}
const payload = {
app: "Pinkudex",
version: 1,
exportedAt: new Date().toISOString(),
tables: data,
};
const json = JSON.stringify(payload, null, 2);
const stamp = new Date().toISOString().replace(/[:.]/g, "-");
return new NextResponse(json, {
headers: {
"Content-Type": "application/json; charset=utf-8",
"Content-Disposition": `attachment; filename="pinkudex-backup-${stamp}.json"`,
"Cache-Control": "no-store",
},
});
}