thiagobustamante / typescript-rest

This is a lightweight annotation-based expressjs extension for typescript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@UserParam Support

jackghicks opened this issue · comments

I find myself quite often needing to reference the currently authenticated user, meaning you need to ensure you have a ServiceContext so that you can do context.request.user.xyz

It seems that it would be cleaner to be able to include a @UserParam user: MyUserType in the arguments for any method where you need a reference to the user - that way, the method definition explicitly shows that the user itself is a critically important input to the method. Using the context works for now, but it is quite vague.

I'm happy to create a PR and implement this if others think it's a good idea!