웹 로그, 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
+18 -32
View File
@@ -1,39 +1,25 @@
import { NextResponse } from "next/server";
import { auth } from "@/auth";
import { getMaestroDetail } from "@/lib/maestros";
import { ApiError } from "@/lib/errors";
import { withApiHandler } from "@/lib/api-handler";
type MaestroDetailRouteContext = {
params: Promise<{
id: string;
}>;
};
export const GET = withApiHandler<{ id: string }>(
"maestros/[id]",
async (_request, { params }) => {
const { id } = await params;
const maestroID = Number(id);
export async function GET(
_request: Request,
{ params }: MaestroDetailRouteContext
) {
const session = await auth();
if (!Number.isInteger(maestroID) || maestroID <= 0) {
throw new ApiError("Invalid maestro id", 400);
}
if (!session) {
return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
const result = await getMaestroDetail(maestroID);
if (!result) {
throw new ApiError("Not found", 404);
}
return NextResponse.json(result);
}
const { id } = await params;
const maestroID = Number(id);
if (!Number.isInteger(maestroID) || maestroID <= 0) {
return NextResponse.json(
{ message: "Invalid maestro id" },
{ status: 400 }
);
}
const result = await getMaestroDetail(maestroID);
if (!result) {
return NextResponse.json({ message: "Not found" }, { status: 404 });
}
return NextResponse.json(result);
}
);
+3 -10
View File
@@ -1,17 +1,10 @@
import { NextResponse } from "next/server";
import { auth } from "@/auth";
import { getMaestros } from "@/lib/maestros";
import { withApiHandler } from "@/lib/api-handler";
export async function GET(request: Request) {
const session = await auth();
if (!session) {
return NextResponse.json({ message: "Unauthorized" }, { status: 401 });
}
export const GET = withApiHandler("maestros", async (request) => {
const url = new URL(request.url);
const result = await getMaestros(url.searchParams);
return NextResponse.json(result);
}
});