From 79e0e5651ab8d499e11272ee5572a64cb6fc8497 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 5 Jun 2024 12:03:10 +0100 Subject: [PATCH] add readme --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c8a779b --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# Paste + +A simple pastebin service. Running at [paste.fascinated.cc](https://paste.fascinated.cc). + +## Javascript Utility + +```js +/** + * Uploads a paste to paste.fascinated.cc + * + * @param content the content of the paste + * @returns the paste key and the URL + */ +async function uploadPaste(content: string) { + const response = await fetch("https://paste.fascinated.cc/api/upload", { + method: "POST", + body: content, + }); + const json = await response.json(); + + if (!response.ok) { + throw new Error(json.message); + } + + return { + ...json, + url: `https://paste.fascinated.cc/${json.key}`, + }; +} + +console.log(await uploadPaste("Hello, World!")); +``` \ No newline at end of file