-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass in contract information within implementation function #298
Comments
@Gabrola I can submit a PR if I have the time, in particular for the Any preference on how would you pass in the infromation? I've messed around a bit with the express integration, and I think it already has something like this within the middlware, which put this kind of information in the request parameter, but I'm not a big fan of that. Just let me know and I'll get the PR ready. |
Yeah feel free to to submit a PR, it's fine if it's just for the nextjs lib. The approach taken in the express lib is to able to have access to the endpoint schema in middleware since they only take the |
This is a nice enchantment, anybody looking into it? I could investigate the nest side. |
@oliverbutler Sadly, I didn't have enough time to start working on anything yet, even though I think it would be a really small change. I was planning on working strictly on the nextjs lib so we probably wouldn't have much conflict anyway. 😄 |
I think it would be very useful to be able to access the contract metadata and possibly other contract information directly inside the implementation function without manually pathing from the contract.
As an example using the
@ts-rest/next
package, but it would be analogous in the other ones.Currently I can do this:
Which works fine, but would be much more intuitive and expandable (IMO) to be able access contract information like this:
or
or some similar way.
This is not really issue or anything, just convenience, but it would be very useful for creating some standard (custom) functionality, like middleware, based on metadata or other contract information, like this for example:
and then use it like this, basically in any route:
The text was updated successfully, but these errors were encountered: