Skip to content

Commit

Permalink
chore: drop axios for native fetch (#1448)
Browse files Browse the repository at this point in the history
* chore: drop axios for native fetch

* chore: update .nvmrc to 21.7.3
  • Loading branch information
mvarendorff authored Oct 5, 2024
1 parent c281abc commit da0a4b4
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.6.1
21.7.3
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"@discordjs/rest": "2.4.0",
"@prisma/client": "5.20.0",
"@sentry/node": "8.33.1",
"axios": "1.7.7",
"countries-and-timezones": "3.7.0",
"country-code-emoji": "2.3.0",
"date-fns": "4.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/common/tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import axios from "axios";
import {
Channel,
Collection,
Expand Down Expand Up @@ -158,8 +157,8 @@ class Tools {
const apiKey = process.env.GOOGLE_API_KEY;
const url = `https://sheets.googleapis.com/v4/spreadsheets/${sheetId}/values/Sheet1?key=${apiKey}`;

const response = await axios.get(url);
const data = await response.data;
const response = await fetch(url);
const data = await response.json();
const rows = data.values;

return rows.flatMap((row: string[]) => row);
Expand Down
5 changes: 4 additions & 1 deletion src/event-distribution/events/slash-commands/add-options.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ApplicationCommandOptionAllowedChannelTypes,
SlashCommandBuilder,
SlashCommandIntegerOption,
SlashCommandNumberOption,
SlashCommandStringOption,
SlashCommandSubcommandBuilder,
ApplicationCommandOptionAllowedChannelTypes,
} from "@discordjs/builders";
import {
APIApplicationCommandBasicOption,
Expand Down Expand Up @@ -141,6 +141,9 @@ const addOption = (
return addMinMax(withChoices, option);
});
break;
case ApplicationCommandOptionType.Attachment:
builder.addAttachmentOption(addDefaults);
break;
}

return builder;
Expand Down
5 changes: 2 additions & 3 deletions src/programs/daily-challenge.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Timer } from "@prisma/client";
import Axios from "axios";
import {
ApplicationCommandOptionType,
ChatInputCommandInteraction,
Expand Down Expand Up @@ -140,8 +139,8 @@ class SaveToDB implements CommandHandler<DiscordEvent.SLASH_COMMAND> {
const challenges = interaction.options.getAttachment("challenges")!;

try {
const file = await Axios.get(challenges.url);
const bulkChallenges: string[] = file.data.split("\n");
const file = await fetch(challenges.url).then((res) => res.text());
const bulkChallenges: string[] = file.split("\n");
const bulkInsert = bulkChallenges.map((challenge) => ({
result: challenge.trim(),
}));
Expand Down
79 changes: 0 additions & 79 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3376,31 +3376,13 @@ __metadata:
languageName: node
linkType: hard

"asynckit@npm:^0.4.0":
version: 0.4.0
resolution: "asynckit@npm:0.4.0"
checksum: 10c0/d73e2ddf20c4eb9337e1b3df1a0f6159481050a5de457c55b14ea2e5cb6d90bb69e004c9af54737a5ee0917fcf2c9e25de67777bbe58261847846066ba75bc9d
languageName: node
linkType: hard

"auto-bind@npm:^4.0.0, auto-bind@npm:~4.0.0":
version: 4.0.0
resolution: "auto-bind@npm:4.0.0"
checksum: 10c0/12f70745d081ba990dca028ecfa70de25d4baa9a8b74a5bef3ab293da56cba32ff8276c3ff8e5fe6d9f370547bf3fa71486befbfefe272af7e722c21d0c25530
languageName: node
linkType: hard

"axios@npm:1.7.7":
version: 1.7.7
resolution: "axios@npm:1.7.7"
dependencies:
follow-redirects: "npm:^1.15.6"
form-data: "npm:^4.0.0"
proxy-from-env: "npm:^1.1.0"
checksum: 10c0/4499efc89e86b0b49ffddc018798de05fab26e3bf57913818266be73279a6418c3ce8f9e934c7d2d707ab8c095e837fc6c90608fb7715b94d357720b5f568af7
languageName: node
linkType: hard

"babel-plugin-syntax-trailing-function-commas@npm:^7.0.0-beta.0":
version: 7.0.0-beta.0
resolution: "babel-plugin-syntax-trailing-function-commas@npm:7.0.0-beta.0"
Expand Down Expand Up @@ -3882,15 +3864,6 @@ __metadata:
languageName: node
linkType: hard

"combined-stream@npm:^1.0.8":
version: 1.0.8
resolution: "combined-stream@npm:1.0.8"
dependencies:
delayed-stream: "npm:~1.0.0"
checksum: 10c0/0dbb829577e1b1e839fa82b40c07ffaf7de8a09b935cadd355a73652ae70a88b4320db322f6634a4ad93424292fa80973ac6480986247f1734a1137debf271d5
languageName: node
linkType: hard

"commander@npm:^4.0.0":
version: 4.1.1
resolution: "commander@npm:4.1.1"
Expand Down Expand Up @@ -4072,13 +4045,6 @@ __metadata:
languageName: node
linkType: hard

"delayed-stream@npm:~1.0.0":
version: 1.0.0
resolution: "delayed-stream@npm:1.0.0"
checksum: 10c0/d758899da03392e6712f042bec80aa293bbe9e9ff1b2634baae6a360113e708b91326594c8a486d475c69d6259afb7efacdc3537bfcda1c6c648e390ce601b19
languageName: node
linkType: hard

"dependency-graph@npm:^0.11.0":
version: 0.11.0
resolution: "dependency-graph@npm:0.11.0"
Expand Down Expand Up @@ -4600,16 +4566,6 @@ __metadata:
languageName: node
linkType: hard

"follow-redirects@npm:^1.15.6":
version: 1.15.9
resolution: "follow-redirects@npm:1.15.9"
peerDependenciesMeta:
debug:
optional: true
checksum: 10c0/5829165bd112c3c0e82be6c15b1a58fa9dcfaede3b3c54697a82fe4a62dd5ae5e8222956b448d2f98e331525f05d00404aba7d696de9e761ef6e42fdc780244f
languageName: node
linkType: hard

"foreground-child@npm:^3.1.0":
version: 3.3.0
resolution: "foreground-child@npm:3.3.0"
Expand All @@ -4620,17 +4576,6 @@ __metadata:
languageName: node
linkType: hard

"form-data@npm:^4.0.0":
version: 4.0.0
resolution: "form-data@npm:4.0.0"
dependencies:
asynckit: "npm:^0.4.0"
combined-stream: "npm:^1.0.8"
mime-types: "npm:^2.1.12"
checksum: 10c0/cb6f3ac49180be03ff07ba3ff125f9eba2ff0b277fb33c7fc47569fc5e616882c5b1c69b9904c4c4187e97dd0419dd03b134174756f296dec62041e6527e2c6e
languageName: node
linkType: hard

"fs-minipass@npm:^2.0.0":
version: 2.1.0
resolution: "fs-minipass@npm:2.1.0"
Expand Down Expand Up @@ -5563,22 +5508,6 @@ __metadata:
languageName: node
linkType: hard

"mime-db@npm:1.52.0":
version: 1.52.0
resolution: "mime-db@npm:1.52.0"
checksum: 10c0/0557a01deebf45ac5f5777fe7740b2a5c309c6d62d40ceab4e23da9f821899ce7a900b7ac8157d4548ddbb7beffe9abc621250e6d182b0397ec7f10c7b91a5aa
languageName: node
linkType: hard

"mime-types@npm:^2.1.12":
version: 2.1.35
resolution: "mime-types@npm:2.1.35"
dependencies:
mime-db: "npm:1.52.0"
checksum: 10c0/82fb07ec56d8ff1fc999a84f2f217aa46cb6ed1033fefaabd5785b9a974ed225c90dc72fff460259e66b95b73648596dbcc50d51ed69cdf464af2d237d3149b2
languageName: node
linkType: hard

"mimic-fn@npm:^2.1.0":
version: 2.1.0
resolution: "mimic-fn@npm:2.1.0"
Expand Down Expand Up @@ -6297,13 +6226,6 @@ __metadata:
languageName: node
linkType: hard

"proxy-from-env@npm:^1.1.0":
version: 1.1.0
resolution: "proxy-from-env@npm:1.1.0"
checksum: 10c0/fe7dd8b1bdbbbea18d1459107729c3e4a2243ca870d26d34c2c1bcd3e4425b7bcc5112362df2d93cc7fb9746f6142b5e272fd1cc5c86ddf8580175186f6ad42b
languageName: node
linkType: hard

"punycode@npm:^1.3.2":
version: 1.4.1
resolution: "punycode@npm:1.4.1"
Expand Down Expand Up @@ -7135,7 +7057,6 @@ __metadata:
"@types/node-cron": "npm:3.0.11"
"@types/ws": "npm:8.5.12"
"@yestheoryfam/prettier-config": "npm:1.0.0"
axios: "npm:1.7.7"
countries-and-timezones: "npm:3.7.0"
country-code-emoji: "npm:2.3.0"
date-fns: "npm:4.1.0"
Expand Down

0 comments on commit da0a4b4

Please sign in to comment.