Skip to content

Commit

Permalink
fix: removed auto-bind, fixed listen/close
Browse files Browse the repository at this point in the history
  • Loading branch information
niftylettuce committed Sep 10, 2019
1 parent 0fcb490 commit 8bec6fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const StoreIPAddress = require('@ladjs/store-ip-address');
const Timeout = require('koa-better-timeout');
const _ = require('lodash');
const auth = require('koa-basic-auth');
const autoBind = require('auto-bind');
const bodyParser = require('koa-bodyparser');
const boolean = require('boolean');
const compress = require('koa-compress');
Expand Down Expand Up @@ -168,17 +167,17 @@ class API {
this.server = server;
this.client = client;

autoBind(this);
// bind listen/close to this
this.listen = this.listen.bind(this);
this.close = this.close.bind(this);
}

async listen(port) {
const { server } = this;
this.server = await util.promisify(server.listen).bind(server)(port);
await util.promisify(this.server.listen).bind(this.server)(port);
}

async close() {
const { server } = this;
this.server = await util.promisify(server.close).bind(server);
await util.promisify(this.server.close).bind(this.server);
}
}

Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"devDependencies": {
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"auto-bind": "^2.1.0",
"ava": "^2.3.0",
"codecov": "^3.5.0",
"cross-env": "^5.2.1",
Expand Down

0 comments on commit 8bec6fa

Please sign in to comment.