From 9d64e0510ce33a80c3c74e2dbbb3d9a69364e247 Mon Sep 17 00:00:00 2001 From: wlodekm Date: Sat, 9 Nov 2024 12:38:31 +0200 Subject: initial --- index.js | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 index.js (limited to 'index.js') diff --git a/index.js b/index.js new file mode 100644 index 0000000..fd9ead0 --- /dev/null +++ b/index.js @@ -0,0 +1,40 @@ +import * as readline from 'node:readline/promises'; +import { stdin as input, stdout as output } from 'node:process'; + +const rl = readline.createInterface({ input, output }); + +const username = await rl.question('Username: '); +const password = await rl.question('Password: '); + +console.log("logging in as %s", username) + +const authr = await (await fetch("https://api.meower.org/auth/login", { + method: "POST", + headers: { + "content-type": "application/json" + }, + body: JSON.stringify({ + username, + password + }) +})).json(); +let token = authr.token + +console.log('got token', token) + +rl.addListener('line', async (i) => { + await fetch("https://api.meower.org/home", { + method: "POST", + headers: { + "content-type": "application/json", + token + }, + body: JSON.stringify({ + content: i + }) + }) + // console.log("sent") + rl.prompt("> ") +}) + +rl.prompt("> ") \ No newline at end of file -- cgit 1.4.1-2-gfad0