사소한 리팩토링

This commit is contained in:
static
2025-01-13 03:33:01 +09:00
parent 6a64bb45f2
commit b8c7cda4d5
3 changed files with 8 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ export const userInfoResponse = z.object({
});
export type UserInfoResponse = z.infer<typeof userInfoResponse>;
export const changeNicknameRequest = z.object({
export const nicknameChangeRequest = z.object({
newNickname: z.string().min(2).max(8),
});
export type ChangeNicknameRequest = z.infer<typeof changeNicknameRequest>;
export type NicknameChangeRequest = z.infer<typeof nicknameChangeRequest>;

View File

@@ -7,6 +7,10 @@
let { data } = $props();
</script>
<svelte:head>
<title>메뉴</title>
</svelte:head>
<div class="sticky top-0 bg-white px-6 py-4">
<p class="font-semibold">{data.nickname}</p>
</div>

View File

@@ -1,13 +1,13 @@
import { error, text } from "@sveltejs/kit";
import { authorize } from "$lib/server/modules/auth";
import { changeNicknameRequest } from "$lib/server/schemas";
import { nicknameChangeRequest } from "$lib/server/schemas";
import { changeNickname } from "$lib/server/services/user";
import type { RequestHandler } from "./$types";
export const POST: RequestHandler = async ({ locals, request }) => {
const { userId } = await authorize(locals, "any");
const zodRes = changeNicknameRequest.safeParse(await request.json());
const zodRes = nicknameChangeRequest.safeParse(await request.json());
if (!zodRes.success) error(400, "Invalid request body");
const { newNickname } = zodRes.data;