Changeset 8fe7f1a for pages/forge/forge.telefunc.ts
- Timestamp:
- 12/28/25 17:27:19 (6 months ago)
- Branches:
- main
- Children:
- 1ac9ee4
- Parents:
- 67186d2
- File:
-
- 1 edited
-
pages/forge/forge.telefunc.ts (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pages/forge/forge.telefunc.ts
r67186d2 r8fe7f1a 5 5 import {removeComponentFromBuild} from "../../database/drizzle/queries"; 6 6 7 export async function on SaveNewBuild({ name, description, componentIds}8 : { name: string; description: string; componentIds: number[]}) {7 export async function onRemoveComponentFromBuild({ buildId, componentId } 8 : { buildId: number, componentId: number }) { 9 9 const { c, userId } = requireUser() 10 10 11 const newBuildId = await drizzleQueries.addNewBuild(c.db, userId, name, description, componentIds);11 const result = await drizzleQueries.removeComponentFromBuild(c.db, userId, buildId, componentId); 12 12 13 if(! newBuildId) throw Abort();13 if(!result) throw Abort(); 14 14 15 15 return { success: true }; 16 16 } 17 17 18 export async function onRemoveComponentFromBuild({ buildId, componentId } 19 : { buildId: number, componentId: number }) { 18 export async function onAddComponentToBuild({ buildId, componentId }: { buildId: number, componentId: number }) { 20 19 const { c, userId } = requireUser() 21 20 22 const result = await drizzleQueries.removeComponentFromBuild(c.db, buildId, componentId); 21 if(!Number.isInteger(buildId) || buildId <= 0) throw Abort(); 22 if(!Number.isInteger(componentId) || componentId <= 0) throw Abort(); 23 24 const result = await drizzleQueries.addComponentToBuild(c.db, userId, buildId, componentId); 23 25 24 26 if(!result) throw Abort(); … … 49 51 } 50 52 51 export async function onAddComponentToBuild({ buildId, componentId }: { buildId: number, componentId: number }) {52 const { c, userId } = requireUser()53 54 if(!Number.isInteger(buildId) || buildId <= 0) throw Abort();55 if(!Number.isInteger(componentId) || componentId <= 0) throw Abort();56 57 const result = await drizzleQueries.addComponentToBuild(c.db, buildId, componentId);58 59 if(!result) throw Abort();60 61 return { success: true };62 }63 64 53 export async function onGetCompatibleComponents({ buildId, componentType, limit, sort } 65 : { db: Database,buildId: number, componentType: string, limit?: number, sort?: string }) {54 : { buildId: number, componentType: string, limit?: number, sort?: string }) { 66 55 const { c, userId } = requireUser() 67 56 … … 74 63 return compatibleComponents; 75 64 } 65 66 export async function onGetBuildState({ db, buildId} 67 :{ db: Database, buildId: number }) { 68 const { c, userId } = requireUser() 69 70 if(!Number.isInteger(buildId) || buildId <= 0) throw Abort(); 71 72 const buildState = await drizzleQueries.getBuildState(c.db, userId, buildId); 73 74 if(!buildState) throw Abort(); 75 76 return buildState; 77 } 78 79 export async function saveBuildState({ db, buildId, name, description } 80 :{ db: Database, buildId: number, name: string, description: string }) { 81 const { c, userId } = requireUser() 82 83 if(!Number.isInteger(buildId) || buildId <= 0) throw Abort(); 84 85 const result = await drizzleQueries.saveBuildState(c.db, userId, buildId, name, description); 86 87 if(!result) throw Abort(); 88 89 return { success: true }; 90 }
Note:
See TracChangeset
for help on using the changeset viewer.
