웹 로그, DB 쿼리문과 결과 로그 출력

This commit is contained in:
2026-06-22 22:34:56 +09:00
parent bcd0ef2af3
commit f384388c67
21 changed files with 706 additions and 214 deletions
+11 -12
View File
@@ -1,6 +1,8 @@
import { z } from "zod";
import { db } from "@/lib/db";
import { logger } from "@/lib/logger";
import { ApiError } from "@/lib/errors";
import { REQUEST_STATUSES } from "@/lib/constants";
import type { Prisma } from "@/lib/generated/prisma/client";
import {
@@ -54,19 +56,10 @@ export type ExtensionRequestListResult = {
status?: number | "all";
};
export class ExtensionRequestActionError extends Error {
constructor(
message: string,
readonly statusCode: number
) {
super(message);
this.name = "ExtensionRequestActionError";
}
}
export async function getExtensionRequests(
rawSearchParams: RawSearchParams = {}
): Promise<ExtensionRequestListResult> {
const t0 = Date.now();
const params = parseExtensionRequestSearchParams(rawSearchParams);
const where = buildExtensionRequestWhere(params);
const skip = (params.page - 1) * params.pageSize;
@@ -96,6 +89,12 @@ export async function getExtensionRequests(
}),
]);
logger.info("extension-requests", "list fetched", {
totalCount,
page: params.page,
duration: Date.now() - t0,
});
return {
items: requests.map(toExtensionRequestListItem),
page: params.page,
@@ -194,11 +193,11 @@ async function getActionTarget(
});
if (!request) {
throw new ExtensionRequestActionError("연장 신청을 찾을 수 없습니다.", 404);
throw new ApiError("연장 신청을 찾을 수 없습니다.", 404);
}
if (request.Status !== REQUEST_STATUSES.REQUESTED) {
throw new ExtensionRequestActionError("이미 처리된 연장 신청입니다.", 409);
throw new ApiError("이미 처리된 연장 신청입니다.", 409);
}
return request;