kaneo (minimalist kanban) fork to experiment adding a tangled integration github.com/usekaneo/kaneo
at main 46 lines 1.0 kB view raw
1import { and, eq } from "drizzle-orm"; 2import { HTTPException } from "hono/http-exception"; 3import db from "../../database"; 4import { projectTable } from "../../database/schema"; 5 6async function updateProject( 7 id: string, 8 name: string, 9 icon: string, 10 slug: string, 11 description: string, 12 isPublic: boolean, 13 workspaceId: string, 14) { 15 const [existingProject] = await db 16 .select() 17 .from(projectTable) 18 .where( 19 and(eq(projectTable.id, id), eq(projectTable.workspaceId, workspaceId)), 20 ); 21 22 const isProjectExisting = Boolean(existingProject); 23 24 if (!isProjectExisting) { 25 throw new HTTPException(404, { 26 message: 27 "Project doesn't exist or doesn't belong to the specified workspace", 28 }); 29 } 30 31 const [updatedWorkspace] = await db 32 .update(projectTable) 33 .set({ 34 name, 35 icon, 36 slug, 37 description, 38 isPublic, 39 }) 40 .where(eq(projectTable.id, id)) 41 .returning(); 42 43 return updatedWorkspace; 44} 45 46export default updateProject;