Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
refactor: convert echo server util to use promises (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Santos authored and Alan Shaw committed Dec 2, 2019
1 parent c9103e9 commit 0605210
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/utils/echo-http-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ module.exports.createServer = () => {

const server = http.createServer(handler)

server.start = (opts, cb) => {
if (typeof opts === 'function') {
cb = opts
opts = {}
}
return server.listen(Object.assign({ port: defaultPort, host: '127.0.0.1' }, opts), cb)
}
server.start = (opts) => new Promise(
(resolve) => server.listen(Object.assign({ port: defaultPort, host: '127.0.0.1' }, opts), resolve)
)

server.stop = (cb) => server.close(cb)
server.stop = () => new Promise((resolve) => server.close(resolve))

return server
}
Expand Down

0 comments on commit 0605210

Please sign in to comment.