Skip to content

Commit 9dde1c8

Browse files
committed
Use native fetch instead of node-fetch
1 parent c562a16 commit 9dde1c8

File tree

3 files changed

+2
-48
lines changed

3 files changed

+2
-48
lines changed

package-lock.json

Lines changed: 0 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"license": "MIT",
1313
"dependencies": {
1414
"finalhandler": "^1.2.0",
15-
"node-fetch": "^2.6.7",
1615
"serve-static": "^1.15.0",
1716
"winston": "^3.13.0",
1817
"winston-daily-rotate-file": "^5.0.0",

src/username.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
const naughty = require('./naughty');
2-
const fetch = require('node-fetch');
32
const logger = require('./logger');
43
const config = require('./config');
5-
const https = require('https');
64

75
/** Maximum length of usernames, inclusive. */
86
const MAX_LENGTH = 20;
@@ -38,10 +36,6 @@ function isGenerated(username) {
3836
return ANONYMIZE.test(username) || username === 'player' || username === 'scratchattach';
3937
}
4038

41-
const agent = new https.Agent({
42-
keepAlive: true
43-
});
44-
4539
/**
4640
* @param {unknown} username
4741
* @returns {Promise<boolean>}
@@ -61,11 +55,11 @@ function isValidUsername(username) {
6155
}
6256
const start = Date.now();
6357
return fetch(API.replace('$username', username), {
58+
keepalive: true,
6459
headers: {
6560
referer: REFERER
6661
},
67-
timeout: 1000 * 10,
68-
agent
62+
signal: AbortSignal.timeout(5000)
6963
})
7064
.then((res) => {
7165
if (res.ok) {

0 commit comments

Comments
 (0)