diff options
author | wlodekm <[email protected]> | 2024-11-09 12:38:31 +0200 |
---|---|---|
committer | wlodekm <[email protected]> | 2024-11-09 12:38:31 +0200 |
commit | 9d64e0510ce33a80c3c74e2dbbb3d9a69364e247 (patch) | |
tree | ee785581b0220a848a8d9ea1512472e16d208a15 /index.js |
initial
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 40 |
1 files changed, 40 insertions, 0 deletions
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 |