getType() in ExecutionContext and ArgumentsHost
See original GitHub issueI’m submitting a…
[ ] Regression
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request (new chapter/page)
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
Current behavior
Expected behavior
Ref https://github.com/nestjs/nest/issues/1581
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
Environment
For Tooling issues:
- Node version: XX
- Platform:
Others:
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Execution context | NestJS - A progressive Node.js framework
These utilities provide information about the current execution context which can be used to build ... Do this with the getType() method of...
Read more >NESTJS Get the execution context within the exception filter
So I found that identification data are in the execution context only for a ... ArgumentsHost): Record<string, unknown> { switch (host.
Read more >ExecutionContext | @nestjs/microservices
Returns a reference to the handler (method) that will be invoked next in the request pipeline. Returns Function. getType. getType<TContext>(): TContext.
Read more >@nestjs/common ExecutionContext TypeScript Examples
getType() === 'http') { // http request const httpContext = context.switchToHttp(); request = httpContext.getRequest(); response = httpContext.
Read more >get_type - Code Search
packages/common/interfaces/features/arguments-host.interface.ts ... current execution context type (string); */; getType<TContext extends ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m proposing a new (small) chapter on writing universal guards and interceptors based on the topic in https://github.com/nestjs/nest/issues/1581, and this new (
getType()
) feature. At the same time, I’m proposing that we simplify the discussion ofArgumentsHost
/ExecutionContext
in the chapters where it’s introduced (Exception Filters, Guards, Interceptors), as these seem to trip people up and introduce concepts that aren’t necessarily relevant when someone is first learning Nest. (And in the spirit that the Overview chapters essentially assume that the user is building in the HTTP context).I’ve already submitted one PR (which was just pushed today) to simplify Exception Filters handling of this topic. I’m going to submit similar revisions for Guards and Interceptors shortly.
Where I could use some help from people like @dantman, @hexonaut, or anyone else who has an interest in this, is a simple use-case description, and basic sample code (tutorial-like), for using
getType()
to write universal components. If you have input on this topic, please reply to this issue. Thanks!Tracking here https://github.com/nestjs/docs.nestjs.com/pull/954