-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersrefactoringKeeping that code clean!Keeping that code clean!
Description
Version: 0.19
Strongly related: #3361
Wasp uses Zod to validate the URLs users specify through the env vars (frontendUrl, databaseUrl, serverUrl, apiUrl etc.) but it doesn't propagate the confirmed URL validity through the type system. It instead continues treating the URLs as strings.
The problem:
- Whenever we're dealing with one of these URLs, we have to double-check whether the URL has already been verified.
- If we forget, we end up with a redundant "Is URL valid" check.
- Finally, if future versions of Wasp stop validating URLs with Zod, we will have to remember to add checks everywhere.
Branding URLs (i.e., saying they're a URLString instead of string) embeds the information "This URL is confirmed be valid" into the type system and solves these problems. Zod has a brand() option we could probably use.
The task:
- Ensure our types reflect what we know about URLs after validating (probably with branded strings)
- Remove all redundant checks and update type signatures acorss Wasp.
- Consider the other possibility: Consider using
URLinstead ofstringfor URLs in our config. #3361 - Think about how this idea affects users and act accordingly.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomersrefactoringKeeping that code clean!Keeping that code clean!