/api/hsk, /api/mek, /api/user 아래의 Endpoint들을 tRPC로 마이그레이션

This commit is contained in:
static
2025-12-25 20:00:15 +09:00
parent aa4a1a74ea
commit 208252f6b2
22 changed files with 192 additions and 288 deletions

View File

@@ -1,14 +1,14 @@
import { error } from "@sveltejs/kit";
import { callGetApi } from "$lib/hooks";
import type { UserInfoResponse } from "$lib/server/schemas";
import { useTRPC } from "$trpc/client";
import type { PageLoad } from "./$types";
export const load: PageLoad = async ({ fetch }) => {
const res = await callGetApi("/api/user", fetch);
if (!res.ok) {
const trpc = useTRPC(fetch);
try {
const { nickname } = await trpc.user.info.query();
return { nickname };
} catch {
error(500, "Internal server error");
}
const { nickname }: UserInfoResponse = await res.json();
return { nickname };
};