blob: fd9ead0dd22f3c248a237698221b597f7ae8c3fc (
plain)
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
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("> ")
|