PilloFoundation / duvet

12 stars 0 forks source link

URL param checking #20

Open PKWadsy opened 2 months ago

PKWadsy commented 2 months ago

When developing apps using Duvet, it is common to use some form or url parameters through either the file system or through adding endpoints with path regexes. Either way, some form of validation should be implemented which makes sure the types the user is using match up with the actual url parameters. This can be done both during a the build step and during development with a typescript plugin, eslint plugin or editor extension

joshuabrownenz commented 2 months ago

We now have a zodValidator object which can manually do it. We just need to automatically infer/require the user to specify the params.

PKWadsy commented 2 months ago

Awesome. However, it would be good to have some way to ensure that the URL parameters (either defined in zod, or otherwise) are consistent with actual parameters in the file directory.

joshuabrownenz commented 2 months ago

Very happy to take a look at it. Sounds quite interesting.

joshuabrownenz commented 2 months ago

@PKWadsy Thinking about it. I wonder if it would be better to make a custom es-lint plugin which can detect when you don't specify the types of your params. The es-lint plugin could also insist on specific formatting and all sorts of other kint stuff.

joshuabrownenz commented 2 months ago

No I think you are right about having a typescript plugin be the best course of action. Unfortunately, working with one is proving to be extraordinarily difficult. So it's definitely not something I'm going to be able to get done in one night haha.