diff --git a/backend/controller/userController.ts b/backend/controller/userController.ts index b6dd2dc..16b858d 100644 --- a/backend/controller/userController.ts +++ b/backend/controller/userController.ts @@ -84,13 +84,16 @@ export const userController = createController({ const settings = await getUserSettings(db, user); return settings; }), - updateSettings: createEndpoint(userSettings, async (input, { db, user }) => { - if (!user) throw new UnauthorizedError("Unauthorized"); - const settings = await getUserSettings(db, user); - const newSettings = { ...settings, ...input }; - await upsertUserSettings(db, user, input); - return newSettings; - }), + updateSettings: createEndpoint( + userSettings.partial(), + async (input, { db, user }) => { + if (!user) throw new UnauthorizedError("Unauthorized"); + const settings = await getUserSettings(db, user); + const newSettings = { ...settings, ...input }; + await upsertUserSettings(db, user, newSettings); + return newSettings; + }, + ), getUserCount: createEndpoint(z.null(), async (_, { db }) => { const count = await getUserCount(db); return count; diff --git a/backend/repositories/userRepository.ts b/backend/repositories/userRepository.ts index 8269ceb..cf4ed27 100644 --- a/backend/repositories/userRepository.ts +++ b/backend/repositories/userRepository.ts @@ -54,7 +54,7 @@ export const getUser = async ( export const getUserSettings = async ( db: BunSQLiteDatabase, user: string, -): Promise => { +): Promise => { const userSettings = await db .select() .from(UserSettings)