웹 로그, 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 { ACTIVATE_STATUSES, REQUEST_STATUSES } from "@/lib/constants";
import type { Prisma } from "@/lib/generated/prisma/client";
import {
@@ -58,19 +60,10 @@ export type UpgradeRequestListResult = {
status?: number | "all";
};
export class UpgradeRequestActionError extends Error {
constructor(
message: string,
readonly statusCode: number
) {
super(message);
this.name = "UpgradeRequestActionError";
}
}
export async function getUpgradeRequests(
rawSearchParams: RawSearchParams = {}
): Promise<UpgradeRequestListResult> {
const t0 = Date.now();
const params = parseUpgradeRequestSearchParams(rawSearchParams);
const where = buildUpgradeRequestWhere(params);
const skip = (params.page - 1) * params.pageSize;
@@ -100,6 +93,12 @@ export async function getUpgradeRequests(
}),
]);
logger.info("upgrade-requests", "list fetched", {
totalCount,
page: params.page,
duration: Date.now() - t0,
});
return {
items: requests.map(toUpgradeRequestListItem),
page: params.page,
@@ -198,14 +197,14 @@ async function getActionTarget(
});
if (!request) {
throw new UpgradeRequestActionError(
throw new ApiError(
"업그레이드 신청을 찾을 수 없습니다.",
404
);
}
if (request.Status !== REQUEST_STATUSES.REQUESTED) {
throw new UpgradeRequestActionError(
throw new ApiError(
"이미 처리된 업그레이드 신청입니다.",
409
);