Web Dev Cody
Web Dev Cody12mo ago

Path params in HTTP router?

I'm not seeing a way in the docs to easily setup a traditional rest API endpoint such as /api/projects/:projectId/feedback does convex parse the path params at all, or would I need to setup my own regex / parse function?
2 Replies
sshader
sshader12mo ago
Convex doesn't have a built in way of doing this, but it's not too hard to integrate with something like Hono for this (https://stack.convex.dev/hono-with-convex, https://github.com/get-convex/convex-helpers/blob/main/packages/convex-helpers/README.md#hono-for-advanced-http-endpoint-definitions)
GitHub
convex-helpers/packages/convex-helpers/README.md at main · get-conv...
A collection of useful code to complement the official packages. - get-convex/convex-helpers
erquhart
erquhart12mo ago
http router does support route prefixes, gets you part of the way there: https://docs.convex.dev/api/classes/server.HttpRouter#route

Did you find this page helpful?