Kevin CATHALY
add an endpoint to api to get an assistant by id (#1020)
c2f5b76 unverified
raw history blame
No virus
421 Bytes
import { collections } from "$lib/server/database";
import { ObjectId } from "mongodb";
export async function GET({ params }) {
const id = params.id;
const assistantId = new ObjectId(id);
const assistant = await collections.assistants.findOne({
_id: assistantId,
});
if (assistant) {
return Response.json(assistant);
} else {
return Response.json({ message: "Assistant not found" }, { status: 404 });
}
}