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

ExpressJoiSwagger.wrapRouter wrapped express app doesn't return http.Server #5

Open
cmmash opened this issue Nov 15, 2019 · 0 comments

Comments

@cmmash
Copy link
Contributor

cmmash commented Nov 15, 2019

Say I initialize my swagger instance in a swaggers.js module as:

const swagger = new ExpressJoiSwagger({
  swaggerDefinition: {},
  ...
module.exports = swagger;

And then in my server file:

const swagger = require('./utils/swagger');
const app = express();

swaggerizedApp = swagger.wrapRouter(app);
const httpServer = swaggerizedApp.listen(SERVER_PORT, () => {
   console.log('swagger joi enabled server listening on ...');
});

But httpServer is undefined. I need it to pass it on to a Socket.IO server.
Is this a bug or am I doing something wrong?

Edit: Yup, found the issue: https://github.com/richardgirges/express-joi-swagger/blob/master/src/index.js#L129


  /**
   * Initiate express app.listen() and build the master swagger definition
   * @param {Object} expressRouter
   * @param {...any} args
   */
  _listen(expressRouter, ...args) {
    this._buildSwaggerDefinition(expressRouter);

    expressRouter.listen(...args); /* <<<<<<< PROBLEM */
  }

the express router listen call result isn't returned.

cmmash added a commit to cmmash/express-joi-swagger that referenced this issue Dec 16, 2019
richardgirges added a commit that referenced this issue May 6, 2020
[fix]: Issue #5 - ExpressJoiSwagger._listen doesn't return node http.Server
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