From db777541ccba1a974d4f3d21d4536aad5742ea25 Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Mon, 7 Aug 2023 16:46:40 +1000 Subject: [PATCH] add login script --- scripts/stress/identify.js | 2 +- scripts/stress/login.js | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scripts/stress/login.js diff --git a/scripts/stress/identify.js b/scripts/stress/identify.js index 9c74c634..2a271bbc 100644 --- a/scripts/stress/identify.js +++ b/scripts/stress/identify.js @@ -3,7 +3,7 @@ require("dotenv").config(); const { OPCODES } = require("../../dist/gateway/util/Constants.js"); const WebSocket = require("ws"); -const ENDPOINT = `ws://localhost:3002?v=9&encoding=json`; +const ENDPOINT = `ws://localhost:3001?v=9&encoding=json`; const TOKEN = process.env.TOKEN; const TOTAL_ITERATIONS = process.env.ITER ? parseInt(process.env.ITER) : 500; diff --git a/scripts/stress/login.js b/scripts/stress/login.js new file mode 100644 index 00000000..473e2e95 --- /dev/null +++ b/scripts/stress/login.js @@ -0,0 +1,17 @@ +const fetch = require("node-fetch"); +const ENDPOINT = process.env.API || "http://localhost:3001"; + +async function main() { + const ret = await fetch(`${ENDPOINT}/api/auth/login`, { + method: "POST", + body: JSON.stringify({ + login: process.argv[2], + password: process.argv[3], + }), + headers: { "content-type": "application/json " }, + }); + + console.log((await ret.json()).token); +} + +main();