question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getType() in ExecutionContext and ArgumentsHost

See original GitHub issue

I’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:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johnbiundocommented, Sep 24, 2019

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 of ArgumentsHost / 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!

0reactions
kamilmysliwieccommented, Jan 28, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found