- wrap root layout with QueryProvider for React Query - replace market UnderConstruction placeholder with MarketClient and real data fetching - implement search, pagination, and sort via search params using getActiveListings - add necessary client components and queries - update dependencies (e.g., prisma, pkg-types)
31 lines
801 B
TypeScript
31 lines
801 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireAuth } from "@/lib/auth/middleware";
|
|
import { getUnreadCount } from "@/lib/prisma/queries/notifications";
|
|
|
|
/**
|
|
* GET /api/notifications/unread-count
|
|
* Retorna a contagem de notificações não lidas do usuário
|
|
*/
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const authResult = await requireAuth(request);
|
|
if (authResult instanceof NextResponse) return authResult;
|
|
|
|
const count = await getUnreadCount(authResult.userId);
|
|
|
|
return NextResponse.json(
|
|
{
|
|
success: true,
|
|
count,
|
|
},
|
|
{ status: 200 }
|
|
);
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ success: false, error: "Erro ao buscar contagem de notificações" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|
|
|