Remove Node-Fetch
This commit is contained in:
parent
367b0b8fe6
commit
2b1644cc03
4 changed files with 19 additions and 24 deletions
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
src/utils.ts
33
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<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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue