Skip to content

Commit

Permalink
comment performance logs [CI Skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
RickyRAV committed Jan 8, 2025
1 parent 54f658c commit f597f52
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions apps/dashboard/src/app/api/v1/rooms/[roomCode]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,36 @@ export const GET = async (
request: NextRequest,
{ params }: { params: { roomCode: string } }
) => {
const startTime = performance.now();
// const startTime = performance.now();
try {
console.log("Starting validation...");
const validationStart = performance.now();
// console.log("Starting validation...");
// const validationStart = performance.now();
const validatedParams = roomSchema.parse(params);
console.log(`Validation took: ${performance.now() - validationStart}ms`);
// console.log(`Validation took: ${performance.now() - validationStart}ms`);

console.log("Starting DB query...");
const queryStart = performance.now();
// console.log("Starting DB query...");
// const queryStart = performance.now();
const room = await db
.select({ max_players: rooms.maxPlayers })
.from(rooms)
.where(eq(rooms.code, validatedParams.roomCode))
.limit(1);
console.log(`DB query took: ${performance.now() - queryStart}ms`);
// console.log(`DB query took: ${performance.now() - queryStart}ms`);

if (!room[0]) {
return NextResponse.json({ error: "Room not found" }, { status: 404 });
}

console.log("Starting response validation...");
const responseValidationStart = performance.now();
// console.log("Starting response validation...");
// const responseValidationStart = performance.now();
const validatedResponse = roomResponseSchema.parse(room[0]);
console.log(
`Response validation took: ${
performance.now() - responseValidationStart
}ms`
);
// console.log(
// `Response validation took: ${
// performance.now() - responseValidationStart
// }ms`
// );

console.log(`Total time: ${performance.now() - startTime}ms`);
// console.log(`Total time: ${performance.now() - startTime}ms`);
return NextResponse.json(validatedResponse);
} catch (error) {
if (error instanceof z.ZodError) {
Expand Down

0 comments on commit f597f52

Please sign in to comment.