More flexible API
See original GitHub issueHi there, first of all thanks for a great job so far!
The library works fine with a one directory that have only one directory with joi schemas But it is not really comfortable otherwise, especially if you have dozen of joi schemas and complex structure in your project
What about breaking major changes in API? why not to use glob
in search joi schema files?
const defaultOutputFile = (srcPath: string, fileName: string) => path.join(
srcPath,
`${path.basename(fileName, '.ts')}.type.ts`
)
export function convertFromDirectory({
schemaFile,
outputFile = defaultOutputFile,
// ...
}{
schemaFile: string | string[];
outputFile?: (scrPath: string, fileName: string) => string
// ...
}) {
// ... implementation
}
Benefits The usage is more flexible and fits more use cases. Below old options can be dropped from API because it could be done by this new realisation
schemaFileSuffix
convertFromDirectory({
schemaFile: './src/**/*.schema.ts',
outputFile: (srcPath: string, fileName: string) => path.join(srcPath, fileName.replace('.schema', '')),
}})
flattenTree
convertFromDirectory({
schemaFile: './src/**/*.schema.ts',
outputFile: (srcPath: string, fileName: string) => path.join('./src/types', fileName),
}})
rootDirectoryOnly
convertFromDirectory({
schemaFile: './src/*.schema.ts',
}})
ignoreFiles
can be be done by glob in a variety of ways out of box
Caveats
I am not sure about indexAllToRoot
— it could be hard to implement
What do you think? Will you accept such PR?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
3 Ways to Make Your API Responses Flexible - Zapier
Most APIs deliver their responses the exact same way to every client. That's by design; developers need to know what to expect.
Read more >Designing a Usable, Flexible, Long-Lasting API - DZone
This DZone Guide article takes a look at how to design a usable, flexible, and long-lasting API. also explore best practices and also ......
Read more >Flexible API - Flexie CRM
Easily integrate Flexie CRM through our RESTful API. Add leads, deals, contacts or accounts from your application without having to access Flexie. Edit...
Read more >Designing and implementing flexible RESTful services - Medium
To clarify the problem a little further, I wanted to use the same client API for all data types e.g. mileage, user, company,...
Read more >The art of creating simple but flexible APIs - Jos de Jong
While Underscores implementation is more flexible, Scott argues that Ramda's more limited implementation may be the better choice because of ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sure.
Dont had much time for work but enough to implement basic features
https://github.com/mo4islona/joi-to-typescript/pull/1
the progress of tests
I have a problem if schemas names will have a collisions (that i have in my own project) of external schemas names and physical file paths To resolve it we must known from what source file path is schema imported (which seems to be a very complicated)
Looking for a solution.
Thankyou I’ll see if i can help