From 26c8e2f5f5938006f30cbd46225335c93e7b708a Mon Sep 17 00:00:00 2001 From: William Harrison Date: Fri, 22 Dec 2023 09:14:55 +0800 Subject: [PATCH] chore: switch to axios --- backend/routers/index.ts | 12 +++++------- package.json | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/backend/routers/index.ts b/backend/routers/index.ts index 3a44cc3..d17d712 100644 --- a/backend/routers/index.ts +++ b/backend/routers/index.ts @@ -1,9 +1,9 @@ import { BusBoyFile, AssFile } from 'ass'; +import axios from 'axios'; import fs from 'fs-extra'; import bb from 'express-busboy'; import crypto from 'crypto'; -import fetch from 'node-fetch'; import { Router } from 'express'; import { Readable } from 'stream'; @@ -93,12 +93,10 @@ router.post('/', rateLimiterMiddleware("upload", UserConfig.config?.rateLimit?.u // Send to Discord webhook try { - await fetch(UserConfig.config.discordWebhook, { - method: "POST", - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ content: `New upload: ${req.ass.host}/${assFile.fakeid}` }) + await axios.post(UserConfig.config.discordWebhook, { + body: JSON.stringify({ + content: `New upload: ${req.ass.host}/${assFile.fakeid}` + }) }) } catch (err) { log.warn("Failed to send request to Discord webhook"); diff --git a/package.json b/package.json index 98e926a..d2470e6 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "@xoi/gps-metadata-remover": "^1.1.2", "any-shell-escape": "^0.1.1", "autoprefixer": "^10.4.16", + "axios": "^1.6.2", "bcrypt": "^5.1.1", "crypto-random-string": "3.3.1", "cssnano": "^6.0.1", @@ -54,7 +55,6 @@ "luxon": "^3.4.4", "memorystore": "^1.6.7", "mysql2": "^3.6.5", - "node-fetch": "^3.3.2", "node-vibrant": "^3.1.6", "pg": "^8.11.3", "pug": "^3.0.2",