diff --git a/Notesnook.Inbox.API/scripts/test.sh b/Notesnook.Inbox.API/scripts/test.sh new file mode 100644 index 0000000..7e5123d --- /dev/null +++ b/Notesnook.Inbox.API/scripts/test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +GNUPGHOME=$(mktemp -d) + +curl -s http://localhost:5264/inbox/public-encryption-key -H "Authorization: $API_KEY" | jq -r .key > "$GNUPGHOME"/pubkey.asc && gpg --batch --homedir "$GNUPGHOME" --import "$GNUPGHOME"/pubkey.asc >/dev/null 2>&1 && KEYID=$(gpg --homedir "$GNUPGHOME" --list-keys --with-colons | awk -F: '/^pub:/ {print $5; exit}') && printf '%s' '{"title":"Test title CLIE S","type":"note","source":"cli","version":1}' | gpg --batch --homedir "$GNUPGHOME" --trust-model always --armor --encrypt -r "$KEYID" | jq -Rs --arg alg "pgp-aes256" '{v:1, cipher:., alg:$alg}' | curl -s -X POST http://localhost:5264/inbox/items -H "Content-Type: application/json" -H "Authorization: $API_KEY" -d @- && rm -rf "$GNUPGHOME" \ No newline at end of file diff --git a/Notesnook.Inbox.API/scripts/test.ts b/Notesnook.Inbox.API/scripts/test.ts new file mode 100644 index 0000000..c88e8ce --- /dev/null +++ b/Notesnook.Inbox.API/scripts/test.ts @@ -0,0 +1,18 @@ +const response = await fetch("http://localhost:5181/inbox", { + method: "POST", + headers: { + Authorization: process.env.API_KEY, + "Content-Type": "application/json", + }, + body: JSON.stringify({ + title: "This is test note 4", + type: "note", + source: "script", + version: 1, + content: { + type: "html", + data: "

This is test note content 3

", + }, + }), +}); +console.log(await response.text());