cowboyd
Explore posts from serversAarktype
•Created by cowboyd on 9/3/2024 in #questions
How to type an expressjs-like route handler based on the path pattern.
If I define an application like:
get('/path/:id?q=:query', handler)
is it possible to look at the structure of the string and infer the type of the parameters that are passed to the handler
function as { id: string; query: string;}
. Given the prevalence of this pattern, I'd expect that someone has attempted it before, but I can't seem to find it in the docs and/or discord.22 replies