List any standards we should use here. This is an open discussion.
DB
Status = PUBLISHED (unpublished = DELISTED), DELETED
Types = PUBLIC, PREMIUM, INVITE, PAID - applies to user/spaces
Report = anything the community based moderation uses
Error Handling
Client Errors report to Error in admin/client/server
back end does throw New App Error
Front end intercepts…
When a status changes to DELETED then we will legitimately DELETE it in 30 days. Content only shows to that user in a special query specifically looking for deleted content from that user.
Front End:
Types should match the DB then add ones for front end processing as needed. Model User should match type User, if needed add front end variables but explain in comments.
Remapping should go to front end as much as possible.
Load props thrugh PageProps and not in the function itself so we call props.whatever object we want. This makes it easier to tell where variables came from at a glance.
res: status: ‘`success`’ for returns when nothing else needed.
Images need to send with image ?? default if image missing
Context and Hooks
- Cookies/Localstorage are only used for initializing. Never read from them except when initializing. Keep them in sync so when the app/client reset they can initialize properly.
- Do not put useEffect’s or useCallback’s in hooks. These cause the hook to recompute every-time the effect fires. Hooks should be pure logic and storage from Context. They should not have any react states like useState or useEffect as the context can handle these and it does a better job anyways.
- Utilize the tanstack query queryClient as much as possible. Tan Stack query is a context management system so any query made can be loaded directly from here. Look at usePost as an example. There is no PostContext as all state management is done in Tan Stack queryClient contexts.