4.1 React Query 설치 및 Provider 구성 o

This commit is contained in:
koreacomp5
2025-10-09 15:13:12 +09:00
parent 8064837422
commit 55c0f6abb1
8 changed files with 113 additions and 4 deletions

16
src/app/QueryProvider.tsx Normal file
View File

@@ -0,0 +1,16 @@
"use client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useState } from "react";
export default function QueryProvider({ children }: { children: React.ReactNode }) {
const [client] = useState(() => new QueryClient());
return (
<QueryClientProvider client={client}>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}

View File

@@ -2,8 +2,13 @@ import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
import { loginSchema } from "@/lib/validation/auth";
import { verifyPassword } from "@/lib/password";
import { getClientKey, isRateLimited } from "@/lib/ratelimit";
export async function POST(req: Request) {
const key = getClientKey(req, "login");
if (isRateLimited(key, 5, 60_000)) {
return NextResponse.json({ error: "Too Many Requests" }, { status: 429 });
}
const body = await req.json();
const parsed = loginSchema.safeParse(body);
if (!parsed.success)

View File

@@ -2,8 +2,13 @@ import { NextResponse } from "next/server";
import { loginSchema } from "@/lib/validation/auth";
import prisma from "@/lib/prisma";
import { verifyPassword } from "@/lib/password";
import { getClientKey, isRateLimited } from "@/lib/ratelimit";
export async function POST(req: Request) {
const key = getClientKey(req, "login");
if (isRateLimited(key, 5, 60_000)) {
return NextResponse.json({ error: "Too Many Requests" }, { status: 429 });
}
const body = await req.json();
const parsed = loginSchema.safeParse(body);
if (!parsed.success)

View File

@@ -1,5 +1,6 @@
import type { Metadata } from "next";
import "./globals.css";
import QueryProvider from "@/app/QueryProvider";
export const metadata: Metadata = {
@@ -14,8 +15,10 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<body>
{children}
<body>
<QueryProvider>
{children}
</QueryProvider>
</body>
</html>
);