casesandberg / play-money

Simple prediction market platform
https://playmoney.dev
12 stars 10 forks source link

Strip undefined values from update api calls #17

Closed casesandberg closed 2 months ago

casesandberg commented 4 months ago

The common pattern for a user updating data is to allow for all data they can change to be passed into the handlers, but strip out any undefined keys they don't provide as to not accidentally override them. Right now there is a hacky transform before the zod parsing, however there is likely a cleaner way to do this (or just abstract to api-helpers package.) See updateComment and updateUserById for messy stripping.