DB-backed workspace + LangGraph agent
This commit is contained in:
27
Frontend/server/api/contacts/[id].get.ts
Normal file
27
Frontend/server/api/contacts/[id].get.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { prisma } from "../../utils/prisma";
|
||||
import { getAuthContext } from "../../utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = await getAuthContext(event);
|
||||
const id = getRouterParam(event, "id");
|
||||
if (!id) throw createError({ statusCode: 400, statusMessage: "id is required" });
|
||||
|
||||
const contact = await prisma.contact.findFirst({
|
||||
where: { id, teamId: auth.teamId },
|
||||
include: { note: { select: { content: true } } },
|
||||
});
|
||||
if (!contact) throw createError({ statusCode: 404, statusMessage: "not found" });
|
||||
|
||||
return {
|
||||
id: contact.id,
|
||||
name: contact.name,
|
||||
avatar: contact.avatarUrl ?? "",
|
||||
company: contact.company ?? "",
|
||||
country: contact.country ?? "",
|
||||
location: contact.location ?? "",
|
||||
email: contact.email ?? "",
|
||||
phone: contact.phone ?? "",
|
||||
description: contact.note?.content ?? "",
|
||||
};
|
||||
});
|
||||
|
||||
23
Frontend/server/api/contacts/[id]/note.put.ts
Normal file
23
Frontend/server/api/contacts/[id]/note.put.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { readBody } from "h3";
|
||||
import { prisma } from "../../../utils/prisma";
|
||||
import { getAuthContext } from "../../../utils/auth";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const auth = await getAuthContext(event);
|
||||
const id = getRouterParam(event, "id");
|
||||
if (!id) throw createError({ statusCode: 400, statusMessage: "id is required" });
|
||||
const body = await readBody<{ content?: string }>(event);
|
||||
const content = (body?.content ?? "").toString();
|
||||
|
||||
const contact = await prisma.contact.findFirst({ where: { id, teamId: auth.teamId } });
|
||||
if (!contact) throw createError({ statusCode: 404, statusMessage: "not found" });
|
||||
|
||||
await prisma.contactNote.upsert({
|
||||
where: { contactId: id },
|
||||
update: { content },
|
||||
create: { contactId: id, content },
|
||||
});
|
||||
|
||||
return { ok: true };
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user