how to attach socket.io to SwaggerExpress

12 views
Skip to first unread message

Aybyd Romero

unread,
Jul 20, 2017, 5:31:44 PM7/20/17
to Swagger
'use strict';

var SwaggerExpress = require('swagger-express-mw');
var app = require('express')();
var io = require('./api/helpers/socketio');

module.exports = app;

var config = {
    appRoot
: __dirname
};

SwaggerExpress.create(config, function(err, swaggerExpress) {
   
if (err) { throw err; }
    swaggerExpress
.register(app);
    app
.listen(10010, function () {
        console
.log('Application is start listening on localhost:10010');
   
});
     io
.on('connection',function(socket){
     console
.log("A user is connected: " + socket.id);
     io
.emit('message', "Welcome")
   
});

});
io
.attach(app);

With that approach, my server is not getting up, got an error on socket.io attaching to app.
Reply all
Reply to author
Forward
0 new messages