4.1 React Query 설치 및 Provider 구성 o
This commit is contained in:
16
src/app/QueryProvider.tsx
Normal file
16
src/app/QueryProvider.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user