summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/exampleFetch.ts30
-rw-r--r--src/index.ts3
-rw-r--r--src/test/server_benchmark.ts39
3 files changed, 41 insertions, 31 deletions
diff --git a/src/exampleFetch.ts b/src/exampleFetch.ts
deleted file mode 100644

index fdcbe933..00000000 --- a/src/exampleFetch.ts +++ /dev/null
@@ -1,30 +0,0 @@ -import fetch from "node-fetch"; - -fetch("https://discord.com/api/v8/auth/mfa/totp", { - headers: { - authorization: "undefined", - "content-type": "application/json", - }, - body: JSON.stringify({ - code: "722608", - ticket: "WzMxMTEyOTM1NzM2MjEzNTA0MSwibG9naW4iXQ.X8LHqg.vTwtZBaLu5W_XMMSvKad1OAaEoA", - login_source: null, - gift_code_sku_id: null, - }), - method: "POST", -}); -/** - * @returns {"token": "mfa.-Rg2AwyP06YdTPmIDt0sqA92T8fBVITLTcXjP7zO_Uhgkg1FA0WERGjJXJyN_dyVDeBnxIWr0w3XiXW8YxVw", "user_settings": {"locale": "en-GB", "theme": "dark"}} - */ - -// token: mfa.-Rg2AwyP06YdTPmIDt0sqA92T8fBVITLTcXjP7zO_Uhgkg1FA0WERGjJXJyN_dyVDeBnxIWr0w3XiXW8YxVw - -fetch("https://discord.com/api/v8/gateway", { - headers: { - authorization: "token", - }, - method: "GET", -}); -/** - * @returns {"url": "wss://gateway.discord.gg"} - */ diff --git a/src/index.ts b/src/index.ts
index 08804687..85859319 100644 --- a/src/index.ts +++ b/src/index.ts
@@ -6,8 +6,9 @@ import { config } from "dotenv"; config(); import { DiscordServer } from "./Server"; -const server = new DiscordServer({ port: 3000 }); +const server = new DiscordServer({ port: 3000 || process.env.PORT }); server.start().catch(console.error); // @ts-ignore global.server = server; +export default server; diff --git a/src/test/server_benchmark.ts b/src/test/server_benchmark.ts new file mode 100644
index 00000000..c582ee89 --- /dev/null +++ b/src/test/server_benchmark.ts
@@ -0,0 +1,39 @@ +// @ts-nocheck +import "missing-native-js-functions"; +import { config } from "dotenv"; +config(); +import { DiscordServer } from "../Server"; +import fetch from "node-fetch"; +import { promises } from "fs"; +const count = 100; + +async function main() { + const server = new DiscordServer({ port: 3000 }); + await server.start(); + + const tasks = []; + for (let i = 0; i < count; i++) { + tasks.push(test()); + } + + await Promise.all(tasks); + + console.log("logging in 5secs"); + setTimeout(async () => { + await test(); + + process.exit(); + }, 5000); +} +main(); + +async function test() { + const res = await fetch("http://localhost:3000/api/v8/guilds/813524615463698433/members/813524464300982272", { + headers: { + authorization: + "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjgxMzUyNDQ2NDMwMDk4MjI3MiIsImlhdCI6MTYxNDAyOTc0Nn0.6WQiU4D5HHRi3sliHOQe1hsW-hZTEttvdtZuNIdviNI", + }, + }); + + return await res.text(); +}