Helper type to extract the type of a handler parameter with applied plugins #1058
m1212e
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I needed to export the type of a derive result of a plugin I wrote. It injects a very complex and implicitly typed permission object to the context. I'm not sure if there is a more elegant way to pull this off but I wrote a quick generic TS helper type which you can use to extract the TS type of a context of an elysia instance type at any given point in your api setup:
usage looks like this:
Obviously you could also access other fields of the context which are non custom and more common like
["cookie"]
or["body"]
or whatever you need!Let me know if this helps you out or if you find a better and more non hacky way of achieving this.
Beta Was this translation helpful? Give feedback.
All reactions