Remove Node-Fetch

This commit is contained in:
Scott Gould 2024-09-25 14:10:43 -04:00
parent 367b0b8fe6
commit 2b1644cc03
No known key found for this signature in database
4 changed files with 19 additions and 24 deletions

View file

@ -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",

View file

@ -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);

View file

@ -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);
}
}
}
}

View file

@ -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<ApiUrls | null>{
@ -31,9 +30,7 @@ export async function getApiUrls(url: string): Promise<ApiUrls | null>{
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);
}
}
}