4 ms·
You have any of this on github?
by random_kris 5y ago
You have any of this on github?
- yasserf 5y agoThe form building part I don't no, I built it for a client that has a few dozen forms with hundreds of fields / options which is hard to keep up with. So we settled on using a csv file that is essentially a products owner way of saying, i want this field on this entity of this type. For example: entity,field,type,constraints delivery,arrived_at,Date,{ before: 0 } And in the form: form,field_1,field_2,... delivery_details,left_at,arrived_at,... Our CI then checks that the field actually exists in the typescript schema, and if not the build fails on our development environment (and suggests the basic SQL to fix it). The company is small enough for us to be able copy the sql into a migration script and let it run without skipping a beat. It's not a magical pill, renaming, deleting and custom migrations need to be dealt with manually. But for the most part 80%_of our changes are additions and this way it just works.
- yasserf 5y agoI am looking to release the setup I use for deployment but tbh it isn't tested (via tests, since I rely on typescript for most of my data shuttling) and there's alot to it so need to write alot of documentation which i don't have time for. But, the jist is, we APIs like this (this can be improved with less generic json schemas): export const updateSamf: APIFunction<UpdateSamf, void> = async ({ database }, { samfId, ...data }) => { if (Object.keys(data).length === 0) { throw new InvalidParametersError('No fields to update') } if (data.title && data.title.length < 3) { throw new InvalidParametersError('Title needs to be at least 3 characters') } if (data.tags) { data.tags = data.tags.map((t) => t.toLowerCase()) } await database.crudUpdate<Samf>('samf', data, { samfId }, new SamfNotFoundError()) if (data.cover && previousCover) { await content.delete(previousCover) } } export const routes: APIRoutes = [{ type: 'patch', route: StudioRoutePath.SAMF_CRUD, func: updateSamf, schema: 'UpdateSamf', permissions: isSamfOwner }]