feat: 补充注释
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
// server/api/images/history/[id].get.ts - 生图历史详情接口:返回当前用户单条记录和完整响应。
|
||||
import type { IImageHistoryDetail } from "#shared/types/openai";
|
||||
import {
|
||||
clearNewApiAuthCookies,
|
||||
@@ -11,6 +12,15 @@ import {
|
||||
toSafeLogError
|
||||
} from "~~/server/utils";
|
||||
|
||||
/**
|
||||
* GET /api/images/history/:id
|
||||
*
|
||||
* 流程:
|
||||
* 1. 从 httpOnly cookie 读取当前用户 ID。
|
||||
* 2. 校验路由参数 id 必须是数字,并转成 BigInt 查询。
|
||||
* 3. 只允许读取当前用户、未软删除的记录。
|
||||
* 4. 返回详情时包含完整上游响应和 Lsky 响应,便于排查单次生图问题。
|
||||
*/
|
||||
export default defineEventHandler(async (event) => {
|
||||
const logger = createApiLogger("images.history.detail");
|
||||
logger.info("开始");
|
||||
@@ -61,6 +71,7 @@ export default defineEventHandler(async (event) => {
|
||||
}
|
||||
});
|
||||
|
||||
/** 校验并解析路由里的生图记录 ID */
|
||||
const parseRecordId = (value: string | undefined): bigint => {
|
||||
if (!value || !/^\d+$/.test(value)) {
|
||||
throw createError({
|
||||
|
||||
Reference in New Issue
Block a user