FigloaldsF
Convex Community6mo ago
6 replies
Figloalds

How do you guys scaffold your Convex backend projects?

Hi I'm working on a new project using Convex and I'm struggling a little bit with code organization now that I'm having more and more things added, but there's still time to organize
I found myself with these 3 categories of things that are not great to have all on the same files:
- Internal helper functions that are snippets of queries or mutations, to be reused in queries, mutations, internal queries, internal mutations
- internal queries and internal mutations, in these I don't validate user role/credential anything, because I'm assuming the public action/mutation/query that is calling them already handled it
- queries, mutations and actions, in these I expect them to be correctly validated

So if I have a large "someModel.ts" file with all of these 3 intermingled I will struggle to organize that and to have the correct mindset that would allow me to guarantee that the public apis are running their proper validation, and I'll also run into naming conflicts because I may need a "getById" that is validated for the frontend to use, but I may also need a "getByIdInternal" for internal methods to use and then I may need to wrap that getByIdInternal function in a internalQuery so that I can do it from an action;
How do you guys organize your code?
Was this page helpful?