omar-dulaimi / prisma-joi-generator

Prisma 2+ generator to emit Joi schemas from your Prisma schema
MIT License
41 stars 9 forks source link

Break up generated Joi files into sub-directories by Table name #6

Open NextStepGuru opened 1 year ago

NextStepGuru commented 1 year ago

Problem

I am using the prisma-joi-generator to create Joi validator objects automatically and import them into my Koa.js project. I then use the Joi object to validate my API inputs. All of this works great. However, when I deploy the code to Google App Engine to test my API. Google throws an error stating too many files in a single directory. I have over 70 tables in my database and this generator creates 1300+ files.

Suggested solution

Break up the generated files by Table-name sub-directory. For example, if the table name is Post then the sub-directory would be ./generated/post/Post*.ts

omar-dulaimi commented 1 year ago

For files inside the objects folder, there's nothing we can do about it. The reason for that being the info Prisma provides us with does not mention to which model this inputType belongs to. The objects folder is actually for the inputObjectTypes that get generated by Prisma.

What we can do though, is break the generated the schemas inside generated/schemas into multiple folders based on model name.

I'm not sure how many files you get generated in the objects folder, so tell me if this solves your issue or not.