2024-11-14 12:16:05 -05:00
|
|
|
import { auth } from '@/app/(auth)/auth';
|
2024-11-15 10:13:21 -05:00
|
|
|
import { getChatsByUserId } from '@/lib/db/queries';
|
2024-10-11 18:00:22 +05:30
|
|
|
|
|
|
|
|
export async function GET() {
|
|
|
|
|
const session = await auth();
|
|
|
|
|
|
|
|
|
|
if (!session || !session.user) {
|
2024-11-14 12:16:05 -05:00
|
|
|
return Response.json('Unauthorized!', { status: 401 });
|
2024-10-11 18:00:22 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const chats = await getChatsByUserId({ id: session.user.id! });
|
|
|
|
|
return Response.json(chats);
|
|
|
|
|
}
|