summary refs log tree commit diff
path: root/api/src/test/server_benchmark.ts
blob: c582ee89690cfa7afd8a19e135c009285df81f69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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();
}