25 lines
722 B
TypeScript
25 lines
722 B
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { requireApiUser } from "@/lib/api-auth";
|
|
import { listImageHistoryForViewer } from "@/lib/db";
|
|
import { jsonError, normalizeError } from "@/lib/http";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const viewer = requireApiUser(request);
|
|
const items = listImageHistoryForViewer({
|
|
viewerId: viewer.id,
|
|
viewerRole: viewer.role,
|
|
});
|
|
|
|
return NextResponse.json({
|
|
ok: true,
|
|
items,
|
|
});
|
|
} catch (error) {
|
|
const normalizedError = normalizeError(error, "读取图片历史失败。");
|
|
return jsonError(normalizedError.message, normalizedError.statusCode);
|
|
}
|
|
}
|