Skip to content

Commit a48e1c1

Browse files
chore: update koa server to use Date.now() (#104)
Fixes #90
1 parent 2009d17 commit a48e1c1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/test-servers/koa_scaffold_server.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,18 @@ app.use(function*(this, next) {
3434
});
3535

3636
app.use(function*(this, next) {
37-
// TODO: Address the fact that new Date()
38-
// is used instead of Date.now()
39-
const start = new Date() as any;
37+
const start = Date.now();
4038
yield next;
41-
const ms = new Date() as any - start;
39+
const ms = Date.now() - start;
4240
this.set('X-Response-Time', ms + 'ms');
4341
});
4442

4543
// logger
4644

4745
app.use(function*(this, next) {
48-
const start = new Date() as any;
46+
const start = Date.now();
4947
yield next;
50-
const ms = new Date() as any - start;
48+
const ms = Date.now() - start;
5149
// eslint-disable-next-line no-console
5250
console.log('%s %s - %s', this.method, this.url, ms);
5351
});

0 commit comments

Comments
 (0)