/api/auth/logout, /api/auth/refreshToken Endpoint 구현

This commit is contained in:
static
2024-12-26 17:44:44 +09:00
parent 45e214d49f
commit a42f26bab1
8 changed files with 160 additions and 51 deletions

View File

@@ -0,0 +1,16 @@
import { error, json } from "@sveltejs/kit";
import { z } from "zod";
import { refreshToken } from "$lib/server/services/auth";
import type { RequestHandler } from "./$types";
export const POST: RequestHandler = async ({ request }) => {
const zodRes = z
.object({
refreshToken: z.string().nonempty(),
})
.safeParse(await request.json());
if (!zodRes.success) error(400, zodRes.error.message);
const { refreshToken: token } = zodRes.data;
return json(await refreshToken(token.trim()));
};