From 2b1644cc038d1955ee895f0d0ac47cbc1b03b4f9 Mon Sep 17 00:00:00 2001 From: Scott Gould Date: Wed, 25 Sep 2024 14:10:43 -0400 Subject: [PATCH] Remove Node-Fetch --- package.json | 5 ++--- src/index.ts | 2 +- src/stats.ts | 3 +-- src/utils.ts | 33 +++++++++++++++------------------ 4 files changed, 19 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index f4f57f8..41b7566 100644 --- a/package.json +++ b/package.json @@ -20,11 +20,10 @@ "compression": "^1.7.4", "eslint-plugin-html": "^8.1.1", "express": "^4.19.2", + "gulp-sourcemaps": "^3.0.0", "gulp-swc": "^2.2.0", - "node-fetch": "^3.3.2", "rimraf": "^6.0.1", - "ts-to-jsdoc": "^2.2.0", - "gulp-sourcemaps":"^3.0.0" + "ts-to-jsdoc": "^2.2.0" }, "devDependencies": { "@eslint/js": "^9.10.0", diff --git a/src/index.ts b/src/index.ts index 3d59b05..e16cef6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,12 +3,12 @@ import compression from"compression"; import express, { Request, Response }from"express"; import fs from"node:fs/promises"; -import fetch from"node-fetch"; import path from"node:path"; import{ observe, uptime }from"./stats.js"; import{ getApiUrls, inviteResponse }from"./utils.js"; import{ fileURLToPath }from"node:url"; import process from"node:process"; + const devmode = (process.env.NODE_ENV || "development") === "development"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); diff --git a/src/stats.ts b/src/stats.ts index 42fd207..6443bff 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -1,6 +1,5 @@ import fs from"node:fs"; import path from"node:path"; -import fetch from"node-fetch"; import{ getApiUrls }from"./utils.js"; import{ fileURLToPath }from"node:url"; @@ -251,4 +250,4 @@ function setStatus(instance: string | Instance, status: boolean): void{ calcStats(instance); } } -} +} \ No newline at end of file diff --git a/src/utils.ts b/src/utils.ts index 05cc353..28dec6b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,23 +1,22 @@ -import fetch from"node-fetch"; import{ Request, Response }from"express"; interface ApiUrls { -api: string; -gateway: string; -cdn: string; -wellknown: string; + api: string; + gateway: string; + cdn: string; + wellknown: string; } interface Invite { -guild: { -name: string; -description?: string; -icon?: string; -id: string; -}; -inviter?: { -username: string; -}; + guild: { + name: string; + description?: string; + icon?: string; + id: string; + }; + inviter?: { + username: string; + }; } export async function getApiUrls(url: string): Promise{ @@ -31,9 +30,7 @@ export async function getApiUrls(url: string): Promise{ const api = info.api; const apiUrl = new URL(api); const policies: any = await fetch( - `${api}${ - apiUrl.pathname.includes("api") ? "" : "api" - }/policies/instance/domains` + `${api}${apiUrl.pathname.includes("api") ? "" : "api"}/policies/instance/domains` ).then(res=>res.json()); return{ api: policies.apiEndpoint, @@ -111,4 +108,4 @@ export async function inviteResponse( }; res.json(jsonResponse); } -} +} \ No newline at end of file