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

feat: add new option for set http module as global module #1041

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

chenc041
Copy link

@chenc041 chenc041 commented Mar 4, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

add new option for set axios as global module

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@chenc041 chenc041 changed the title feat: add new option for set module as global module feat: add new option for set http module as global module Mar 4, 2024
@micalevisk
Copy link
Member

we should expose a .forRoot/.forRootAsync static method instead of changing the .register. See https://docs.nestjs.com/fundamentals/dynamic-modules#community-guidelines

@chenc041
Copy link
Author

chenc041 commented Mar 4, 2024

static forRoot(config: HttpModuleOptions): DynamicModule {
    return {
      module: HttpModule,
      global: config.global,
      providers: [
        {
          provide: AXIOS_INSTANCE_TOKEN,
          useValue: Axios.create(config),
        },
        {
          provide: HTTP_MODULE_ID,
          useValue: randomStringGenerator(),
        },
      ],
    };
  }

you mean like this ?

@micalevisk
Copy link
Member

micalevisk commented Mar 4, 2024

yeah, I think so. But global must be true

and a .forRootAsync as well

@chenc041
Copy link
Author

chenc041 commented Mar 4, 2024

yeah, I think so. But global must be true

and a .forRootAsync as well

ok, I has changed

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

Successfully merging this pull request may close these issues.

None yet

2 participants