mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-06-15 22:38:48 +00:00
16 lines
398 B
TypeScript
16 lines
398 B
TypeScript
import db from '@/lib/db';
|
|
|
|
export const GET = async (req: Request) => {
|
|
try {
|
|
let chats = await db.query.chats.findMany();
|
|
chats = chats.reverse();
|
|
return Response.json({ chats: chats }, { status: 200 });
|
|
} catch (err) {
|
|
console.error('Error in getting chats: ', err);
|
|
return Response.json(
|
|
{ message: 'An error has occurred.' },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
};
|