Skip to content

Commit 8bec6fa

Browse files
committed
fix: removed auto-bind, fixed listen/close
1 parent 0fcb490 commit 8bec6fa

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

index.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const StoreIPAddress = require('@ladjs/store-ip-address');
1010
const Timeout = require('koa-better-timeout');
1111
const _ = require('lodash');
1212
const auth = require('koa-basic-auth');
13-
const autoBind = require('auto-bind');
1413
const bodyParser = require('koa-bodyparser');
1514
const boolean = require('boolean');
1615
const compress = require('koa-compress');
@@ -168,17 +167,17 @@ class API {
168167
this.server = server;
169168
this.client = client;
170169

171-
autoBind(this);
170+
// bind listen/close to this
171+
this.listen = this.listen.bind(this);
172+
this.close = this.close.bind(this);
172173
}
173174

174175
async listen(port) {
175-
const { server } = this;
176-
this.server = await util.promisify(server.listen).bind(server)(port);
176+
await util.promisify(this.server.listen).bind(this.server)(port);
177177
}
178178

179179
async close() {
180-
const { server } = this;
181-
this.server = await util.promisify(server.close).bind(server);
180+
await util.promisify(this.server.close).bind(this.server);
182181
}
183182
}
184183

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
"devDependencies": {
5151
"@commitlint/cli": "^8.1.0",
5252
"@commitlint/config-conventional": "^8.1.0",
53-
"auto-bind": "^2.1.0",
5453
"ava": "^2.3.0",
5554
"codecov": "^3.5.0",
5655
"cross-env": "^5.2.1",

0 commit comments

Comments
 (0)