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

ExpressAdapter exposes the wrong Http Server #1017

Closed
BrunnerLivio opened this issue Aug 29, 2018 · 3 comments
Closed

ExpressAdapter exposes the wrong Http Server #1017

BrunnerLivio opened this issue Aug 29, 2018 · 3 comments

Comments

@BrunnerLivio
Copy link
Member

BrunnerLivio commented Aug 29, 2018

I'm submitting a...


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

Current behavior

When using Nest with the Express adapter it returns the wrong Http Server when calling HttpServer.getHttpServer().

Example with ExpressAdapter

// main.ts
const app = await NestFactory.create(AppModule);
....
// app.service.ts
@Injectable()
export class AppService {
  constructor(
    @Inject(HTTP_SERVER_REF)
  private server) {
    // Prints "EventEmitter" --> Wrong
    console.log(this.server.getHttpServer().constructor.name);
...

Example with FastifyAdapter

// main.ts
const app = await NestFactory.create(AppModule, new FastifyAdapter());
....
// app.service.ts
@Injectable()
export class AppService {
  constructor(
    @Inject(HTTP_SERVER_REF)
  private server) {
    // Prints "Server" (instance of the http package) --> Good
    console.log(this.server.getHttpServer().constructor.name);
...

Expected behavior

getHttpServer should expose the server instance of the http npm package independent of the adapter.

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

The http.server instance is needed for the terminus implementation --> See #966

@kamilmysliwiec
Copy link
Member

It should be fixed in the v5.3.0

@BrunnerLivio
Copy link
Member Author

BrunnerLivio commented Aug 31, 2018

@kamilmysliwiec Just checked and it works like a charm. Thanks a lot for the quick fix!

@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

2 participants