feat(project): init
This commit is contained in:
24
app/api/images/route.ts
Normal file
24
app/api/images/route.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user