mattstyles / koa-socket

Sugar for connecting socket.io to a koa instance
242 stars 50 forks source link

use existing app.server #13

Closed laggingreflex closed 8 years ago

laggingreflex commented 8 years ago

Checks to see if app.server exists, if so, uses that, if not, creates one.

Wraps app.listen with warning only if app.server was created here.

Doesn't throw error if app.server exists (this is causing to fail 1 test in attach.test.js 'should not alter a koa app that already has .server')

mattstyles commented 8 years ago

Yeah, looks good to me. Can you fix up the test or remove it and I'll merge it in!

Thanks

laggingreflex commented 8 years ago

Updated. It also checks now whether app.server if already exists is actually an http server. (app.server.constructor.name should be "Server"), just in case.

Updated tests.

mattstyles commented 8 years ago

Thats awesome!

Thanks!

laggingreflex commented 8 years ago

publish to npm please

mattstyles commented 8 years ago

Yep, all in 4.1.0. I was going to add some other stuff but that'll take longer so it's up now.