From 5a262b4cf62a0ca92d1e571079ae4a99eb3f65fb Mon Sep 17 00:00:00 2001 From: Khafra <42794878+KhafraDev@users.noreply.github.com> Date: Tue, 28 Sep 2021 21:27:53 -0400 Subject: [PATCH] refactor: node-fetch to undici Follow up to https://github.com/sapphiredev/plugins/pull/143 --- package.json | 1 - packages/api/package.json | 4 +- packages/api/src/lib/structures/http/Auth.ts | 2 +- packages/api/src/routes/oauth/callback.ts | 2 +- packages/api/src/routes/oauth/logout.ts | 2 +- yarn.lock | 45 +++++++++++++------- 6 files changed, 34 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 7680a4372..d73ea4f77 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "@sapphire/utilities": "^3.7.0", "@types/jest": "^28.1.6", "@types/node": "^18.0.6", - "@types/node-fetch": "^2.6.2", "@types/ws": "^8.5.3", "@typescript-eslint/eslint-plugin": "^5.30.7", "@typescript-eslint/parser": "^5.30.7", diff --git a/packages/api/package.json b/packages/api/package.json index 7f5e7dd75..dd7ac4303 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -36,12 +36,12 @@ "check-update": "cliff-jumper --dry-run" }, "dependencies": { - "@types/node-fetch": "2.6.2", "@types/psl": "^1.1.0", "@types/ws": "^8.5.3", "node-fetch": "2.6.7", "psl": "^1.9.0", - "tslib": "^2.4.0" + "tslib": "^2.4.0", + "undici": "^4.7.0" }, "repository": { "type": "git", diff --git a/packages/api/src/lib/structures/http/Auth.ts b/packages/api/src/lib/structures/http/Auth.ts index 863cd5514..61adc264f 100644 --- a/packages/api/src/lib/structures/http/Auth.ts +++ b/packages/api/src/lib/structures/http/Auth.ts @@ -8,7 +8,7 @@ import { Routes, RouteBases } from 'discord-api-types/v9'; -import fetch from 'node-fetch'; +import { fetch } from 'undici'; export class Auth { /** diff --git a/packages/api/src/routes/oauth/callback.ts b/packages/api/src/routes/oauth/callback.ts index 0998383fd..370cf87e5 100644 --- a/packages/api/src/routes/oauth/callback.ts +++ b/packages/api/src/routes/oauth/callback.ts @@ -1,6 +1,6 @@ import type { PieceContext } from '@sapphire/pieces'; import { OAuth2Routes, RESTPostOAuth2AccessTokenResult, RESTPostOAuth2AccessTokenURLEncodedData } from 'discord-api-types/v9'; -import fetch from 'node-fetch'; +import { fetch } from 'undici'; import { stringify } from 'querystring'; import type { ApiRequest } from '../../lib/structures/api/ApiRequest'; import type { ApiResponse } from '../../lib/structures/api/ApiResponse'; diff --git a/packages/api/src/routes/oauth/logout.ts b/packages/api/src/routes/oauth/logout.ts index 0976e8e2b..3f07911f3 100644 --- a/packages/api/src/routes/oauth/logout.ts +++ b/packages/api/src/routes/oauth/logout.ts @@ -1,5 +1,5 @@ import { OAuth2Routes } from 'discord-api-types/v9'; -import fetch from 'node-fetch'; +import { fetch } from 'undici'; import { stringify } from 'querystring'; import { promisify } from 'util'; import type { ApiRequest } from '../../lib/structures/api/ApiRequest'; diff --git a/yarn.lock b/yarn.lock index 276e75e02..50ead8eaa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1094,12 +1094,12 @@ __metadata: linkType: hard "@npmcli/fs@npm:^1.0.0": - version: 1.1.1 - resolution: "@npmcli/fs@npm:1.1.1" + version: 1.0.0 + resolution: "@npmcli/fs@npm:1.0.0" dependencies: "@gar/promisify": ^1.0.1 semver: ^7.3.5 - checksum: f5ad92f157ed222e4e31c352333d0901df02c7c04311e42a81d8eb555d4ec4276ea9c635011757de20cc476755af33e91622838de573b17e52e2e7703f0a9965 + checksum: f2b4990107dd2a5b18794c89aaff6f62f3a67883d49a20602fdfc353cbc7f8c5fd50edeffdc769e454900e01b8b8e43d0b9eb524d00963d69f3c829be1a2e8ac languageName: node linkType: hard @@ -1215,7 +1215,6 @@ __metadata: resolution: "@sapphire/plugin-api@workspace:packages/api" dependencies: "@favware/cliff-jumper": ^1.8.5 - "@types/node-fetch": 2.6.2 "@types/psl": ^1.1.0 "@types/ws": ^8.5.3 gen-esm-wrapper: ^1.1.3 @@ -1223,6 +1222,7 @@ __metadata: psl: ^1.9.0 tslib: ^2.4.0 typescript: ^4.7.4 + undici: ^4.7.0 languageName: unknown linkType: soft @@ -1591,7 +1591,7 @@ __metadata: languageName: node linkType: hard -"@types/node-fetch@npm:2.6.2, @types/node-fetch@npm:^2.6.2": +"@types/node-fetch@npm:^2.6.2": version: 2.6.2 resolution: "@types/node-fetch@npm:2.6.2" dependencies: @@ -1601,7 +1601,14 @@ __metadata: languageName: node linkType: hard -"@types/node@npm:*, @types/node@npm:>=12, @types/node@npm:^18.0.6": +"@types/node@npm:*": + version: 16.10.2 + resolution: "@types/node@npm:16.10.2" + checksum: 83c1c3c68e7500103908c3f16094e458879c840a719c15b6ea577f81fe1f24a1b3473bb6c8e8091fe79a82543ca7639c6b1088fcf80292ec091d1d1c9504a87e + languageName: node + linkType: hard + +"@types/node@npm:>=12, @types/node@npm:^18.0.6": version: 18.0.6 resolution: "@types/node@npm:18.0.6" checksum: 780f8885a6b6eb12f4c0246617747fdc37a451931b3c01ce8148d356c0903b705dcb16cc6a914de63d48b0dc1b002c7a3dfae681f580e1761aa551d3cd996813 @@ -2387,9 +2394,9 @@ __metadata: linkType: hard "camelcase@npm:^6.2.0": - version: 6.3.0 - resolution: "camelcase@npm:6.3.0" - checksum: 8c96818a9076434998511251dcb2761a94817ea17dbdc37f47ac080bd088fc62c7369429a19e2178b993497132c8cbcf5cc1f44ba963e76782ba469c0474938d + version: 6.2.0 + resolution: "camelcase@npm:6.2.0" + checksum: 8335cfd0ecc472eae685896a42afd8c9dacd193a91f569120b931c87deb053a1ba82102031b9b48a4dbc1d18066caeacf2e4ace8c3c7f0d02936d348dc0b5a87 languageName: node linkType: hard @@ -2632,9 +2639,9 @@ __metadata: linkType: hard "commander@npm:^8.2.0": - version: 8.3.0 - resolution: "commander@npm:8.3.0" - checksum: 0f82321821fc27b83bd409510bb9deeebcfa799ff0bf5d102128b500b7af22872c0c92cb6a0ebc5a4cf19c6b550fba9cedfa7329d18c6442a625f851377bacf0 + version: 8.2.0 + resolution: "commander@npm:8.2.0" + checksum: e868805bc266777f7a9c8a740e15b9e02b8148d8251f577ea9b9ef373ac0bdeb77b9b60cfc033592c9e1affea89993be08c13c623f0c619f9bf152c0e4d12cb0 languageName: node linkType: hard @@ -4239,14 +4246,14 @@ __metadata: linkType: hard "import-local@npm:^3.0.2": - version: 3.1.0 - resolution: "import-local@npm:3.1.0" + version: 3.0.3 + resolution: "import-local@npm:3.0.3" dependencies: pkg-dir: ^4.2.0 resolve-cwd: ^3.0.0 bin: import-local-fixture: fixtures/cli.js - checksum: bfcdb63b5e3c0e245e347f3107564035b128a414c4da1172a20dc67db2504e05ede4ac2eee1252359f78b0bfd7b19ef180aec427c2fce6493ae782d73a04cddd + checksum: 38ae57d35e7fd5f63b55895050c798d4dd590e4e2337e9ffa882fb3ea7a7716f3162c7300e382e0a733ca5d07b389fadff652c00fa7b072d5cb6ea34ca06b179 languageName: node linkType: hard @@ -6737,7 +6744,6 @@ __metadata: "@sapphire/utilities": ^3.7.0 "@types/jest": ^28.1.6 "@types/node": ^18.0.6 - "@types/node-fetch": ^2.6.2 "@types/ws": ^8.5.3 "@typescript-eslint/eslint-plugin": ^5.30.7 "@typescript-eslint/parser": ^5.30.7 @@ -7766,6 +7772,13 @@ __metadata: languageName: node linkType: hard +"undici@npm:^4.7.0": + version: 4.7.0 + resolution: "undici@npm:4.7.0" + checksum: bfa38ba56f2d90c1c6b9eb2e5cfd8e183c79062c81edf1aa35f24f504bcd474c4c117b48ba97f2e510c1627f48ca2f2eb3bf712e2da1bce6ec2bf87b223e9625 + languageName: node + linkType: hard + "unique-filename@npm:^1.1.1": version: 1.1.1 resolution: "unique-filename@npm:1.1.1"