mirror of
https://github.com/streetwriters/notesnook-sync-server.git
synced 2026-03-28 22:10:48 +01:00
inbox: add scripts for testing inbox api locally
This commit is contained in:
5
Notesnook.Inbox.API/scripts/test.sh
Normal file
5
Notesnook.Inbox.API/scripts/test.sh
Normal file
@@ -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"
|
||||
18
Notesnook.Inbox.API/scripts/test.ts
Normal file
18
Notesnook.Inbox.API/scripts/test.ts
Normal file
@@ -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: "<p>This is test note content 3</p>",
|
||||
},
|
||||
}),
|
||||
});
|
||||
console.log(await response.text());
|
||||
Reference in New Issue
Block a user