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

HttpModule async registration #1257

Closed
Morb0 opened this issue Nov 2, 2018 · 6 comments
Closed

HttpModule async registration #1257

Morb0 opened this issue Nov 2, 2018 · 6 comments

Comments

@Morb0
Copy link

Morb0 commented Nov 2, 2018

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

HttpModule dont have async registration because of this, it is not possible to set config variables.

Expected behavior

Async module registation with the possibility of inject dependencies through inject

Minimal reproduction of the problem with instructions

imports: [
  HttpModule.register({
    baseURL: 'http://example.com',
    headers: {
      authorization: `Bearer ${configService.get('AUTH_TOKEN')}`,
    }
  })
]

What is the motivation / use case for changing the behavior?

More convenient use of the module

Environment


Nest version: 5.1.0

 
For Tooling issues:
- Node version: 10.11.0  
- Platform: Windows 

Others:

@kamilmysliwiec
Copy link
Member

Done in #1347

@kamilmysliwiec
Copy link
Member

Added in 5.5.0.

@cschroeter
Copy link

@kamilmysliwiec

Instead of

export interface HttpModuleOptions extends AxiosRequestConfig {
}
export interface HttpModuleOptionsFactory {
    createHttpOptions(): Promise<HttpModuleOptions> | HttpModuleOptions;
}
export interface HttpModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
    useExisting?: Type<HttpModuleOptions>;
    useClass?: Type<HttpModuleOptions>;
    useFactory?: (...args: any[]) => Promise<HttpModuleOptions> | HttpModuleOptions;
    inject?: any[];
    extraProviders?: Provider[];
}

shouln't it be

export interface HttpModuleOptions extends AxiosRequestConfig {
}
export interface HttpModuleOptionsFactory {
    createHttpOptions(): Promise<HttpModuleOptions> | HttpModuleOptions;
}
export interface HttpModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
    useExisting?: Type<HttpModuleOptionsFactory>;
    useClass?: Type<HttpModuleOptionsFactory>;
    useFactory?: (...args: any[]) => Promise<HttpModuleOptions> | HttpModuleOptions;
    inject?: any[];
    extraProviders?: Provider[];
}

@kamilmysliwiec
Copy link
Member

Would you like to create PR @cschroeter ?

@cschroeter
Copy link

@kamilmysliwiec ah sorry haven't seen ur reply. will try to creat a pr after holiday season next year

@lock
Copy link

lock bot commented Sep 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants