Skip to content
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

Improve documentation for APP_* providers #2178

Open
1 of 5 tasks
adam-kiss-sg opened this issue Jan 21, 2022 · 0 comments
Open
1 of 5 tasks

Improve documentation for APP_* providers #2178

adam-kiss-sg opened this issue Jan 21, 2022 · 0 comments

Comments

@adam-kiss-sg
Copy link

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.

Documentation Request

APP_* providers (eg: a provider for APP_GUARD) work very differently from other custom providers. For example, you can register multiple providers for them, eg:

    {
      provide: APP_GUARD,
      useClass: AuthGuard('jwt'),
    },
    {
      provide: APP_GUARD,
      useClass: GroupGuard,
    }

They also are not "real" providers, in the sense that they can't be retreived from the DI container, eg this will return an error:

app.get(APP_GUARD)

For me it was kind of confusing, until I read the source code:
https://github.com/nestjs/nest/blob/master/packages/core/scanner.ts#L491

It might be worth to update the custom providers documentation with some more details about these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant