From 6857914c3b738d7fb31747c79c649816d287aa5c Mon Sep 17 00:00:00 2001 From: Soham Sen Date: Tue, 13 Jun 2023 19:02:07 +0530 Subject: [PATCH] We are at v1.0.0! --- API.md | 62 ++++++++++++++++++++++++++++++++ README.md | 13 ++++++- package.json | 2 +- src/app.html | 2 +- src/lib/types.ts | 12 +++---- src/routes/api/paste/+server.ts | 8 ++--- src/routes/info/+page.svelte | 25 +++++++++---- static/yabin-logo.ico | Bin 0 -> 4286 bytes static/yabin-logo.svg | 9 +++++ 9 files changed, 113 insertions(+), 20 deletions(-) create mode 100644 API.md create mode 100644 static/yabin-logo.ico create mode 100644 static/yabin-logo.svg diff --git a/API.md b/API.md new file mode 100644 index 0000000..2950f44 --- /dev/null +++ b/API.md @@ -0,0 +1,62 @@ +# API + +## Create a paste + +### Request + +**Method:** `POST /api/paste` + +#### Body + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| `content` | `string` | Paste content. If encrypted, must be encoded into a string (preferably Base64). | Yes | +| `config` | `object` | Configuration for the paste | No | +| `passwordProtected` | `boolean` | Whether the paste is password protected. | No | +| `initVector` | `string` | Initialization vector for AES encryption. Max length: 64. | No | + +**Config Object:** + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| `language` | `string` | Programming language of the paste. Default: `plaintext`. | No | +| `encrypted` | `boolean` | Whether the paste is encrypted. Default: `false`. | No | +| `expiresAfter` | `number` | Time in seconds until the paste expires. | No | +| `burnAfterRead` | `boolean` | Whether the paste is deleted after reading. | No | + +### Examples + +```json +{ + "content": "i0n3PW6qDUhDaTrzoKg+/ip4qQwu+iq8/fWDVg==", + "config": { + "language": "plaintext", + "encrypted": true, + "expiresAfter": 3600, + "burnAfterRead": false + }, + "passwordProtected": false, + "initVector": "27DIWK00yDiGx001" +} +``` + +```json +{ + "content": "Hello World!", + "config": { + "language": "plaintext" + } +} +``` + +## Get a paste + +### Request + +**Method:** `GET /api/paste` + +#### Query Parameters + +| Name | Type | Description | Required | +| ---- | ---- | ----------- | -------- | +| `key` | `string` | Paste key. | Yes | diff --git a/README.md b/README.md index f97d553..62dea3c 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,12 @@ Well, cause no pastebin I could find had ALL of the following features: - API support to create and get pastes from command line. - View raw pastes. Normally, encrypted pastebins do not have this. With this site, you can either get the Base64-encoded encrypted paste, or decrypt it on the server side (even with the password) and get the raw paste. - Keyboard shortcuts! - - And ofcourse, being fully open-source and easily self-hostable. + - And of course, being fully open-source and easily self-hostable. + - **It can even be run on edge servers and in serverless environments!** + + ## API Documentation + +See [API.md](API.md). ## How to use @@ -34,3 +39,9 @@ yarn dev docker build -t yabin:latest . docker run --env-file .env -it -p 3000:3000 yabin:latest ``` + +#### In a serverless environment (Cloudflare Workers, Netlify, Vercel, etc.) + +I have not yet tested this, but this is made with SvelteKit. Please take a look at the [SvelteKit documentation](https://kit.svelte.dev/docs/adapters) for more information. If there are any issues, please open an issue, and I will put up a proper guide on how to deploy on such environmments. + +**Right now, it is using PostgreSQL (cause I had a server lying around). However, it can be run using any SQL DB such as SQLite or MySQL. To use other backends, please update the provider in [schema.prisma](src/lib/server/prisma/schema.prisma)** \ No newline at end of file diff --git a/package.json b/package.json index fbfe96c..f8574e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yabin", - "version": "0.0.1", + "version": "1.0.0", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/app.html b/src/app.html index 0e86b82..113f6ff 100644 --- a/src/app.html +++ b/src/app.html @@ -7,7 +7,7 @@ - + YABin %sveltekit.head% diff --git a/src/lib/types.ts b/src/lib/types.ts index 778ad4f..0bcd6ed 100644 --- a/src/lib/types.ts +++ b/src/lib/types.ts @@ -1,14 +1,14 @@ export interface PasteConfig { - language: string; - encrypted: boolean; - expiresAfter: number; - burnAfterRead: boolean; + language?: string; + encrypted?: boolean; + expiresAfter?: number; + burnAfterRead?: boolean; } export interface Paste { content: string; - config: PasteConfig; - passwordProtected: boolean; + config?: PasteConfig; + passwordProtected?: boolean; initVector?: string; } diff --git a/src/routes/api/paste/+server.ts b/src/routes/api/paste/+server.ts index c2bfc12..bbb83fc 100644 --- a/src/routes/api/paste/+server.ts +++ b/src/routes/api/paste/+server.ts @@ -53,12 +53,12 @@ export const POST: RequestHandler = async ({ request }) => { data: { key, content, - language: config.language, - encrypted: config.encrypted, + language: config?.language ?? 'plaintext', + encrypted: config?.encrypted ?? false, passwordProtected, - expiresCount: config.burnAfterRead ? 2 : null, + expiresCount: config?.burnAfterRead ? 2 : null, initVector, - expiresAt: config.expiresAfter ? new Date(Date.now() + config.expiresAfter * 1000) : null + expiresAt: config?.expiresAfter ? new Date(Date.now() + config.expiresAfter * 1000) : null } }); diff --git a/src/routes/info/+page.svelte b/src/routes/info/+page.svelte index bb62963..3f674ac 100644 --- a/src/routes/info/+page.svelte +++ b/src/routes/info/+page.svelte @@ -88,17 +88,25 @@ href="https://github.com/Yureien/YABin">open-source and easily self-hostable. +
  • It can even be run in serverless environments!
  • + +

    + The API documentation is available here. +

    Support the development

    -

    +

    If you really like this project, I'd love it if you Buy Me a Coffee at ko-fi.com me on GitHub.

    -

    - Soon, after the development is mostly complete, I will be running managed servers on a - custom and short domain. You can also support me by subscribing to a monthly service, and - you get your own pastebin, with your custom styles, colours, text and more! +

    + Soon, I will be running managed servers on a custom and short domain. You can support me by + subscribing to a monthly service, and you get your own pastebin, with your custom styles, + colours, text and more! If you are interested, please send me an email at contact@sohamsen.me, and I will get back to you as soon as possible.

    diff --git a/static/yabin-logo.ico b/static/yabin-logo.ico new file mode 100644 index 0000000000000000000000000000000000000000..34e9a7a0af93c7e37b93049cdba8ac1a8aa9d746 GIT binary patch literal 4286 zcmc&&X>1i$6n=%ayfW|2doyp|R+g5ww1v`ERw*E|MuoE5vb4p50unTU7HFX0!m1{K z3Wc)BrU)@^kwz*6MRp7c2tPDxL>4tfabZ;xKhL?toi1-)ZRCe-F1K^3?!W!o$yc7Qs_QV~; zk=S$C9bb+6y}hj%g2YK*Z!f$ZUxN?gKEb}&6FAxYE7ZgtLv`Gzc-dJ+F^7fUG+!IM z75^cYC#)oVlSk%sm}e*s#h%4b&qH8r9wR)%a5?4{wzSxdURn=i_>w86L1cFtd*hB$ z9w}BWn3HZ=F1l#hn5~rIV$2Opc0Y=)^voP28oIDe_a)&d<*>>5x^*@{ScPfT4cyK@99OQcBtdS4ak{hk) zUUE#_LB9QU+* zQOCyeG2`HRe2{X`jAoSwpFa}RT z*sn+C$u_xtpcgG8n^Jol3!A<#QZk_zE`qOM0Yb@XBCn|Ux(mM1bD_NPH#~FSM>t@k z4dRCJU6tR%z4A*0)3c*BUv~1N?nP)jMb1KaPQQn4JgLnu}1EeTGomcBT%fHes(5#=sK6 zji+KiLaka+9<_bgHhe&zvFdu=$*Nf;_(Syg4sRcdi6qt z?riaycfwPbpMtXS7r`6fr%=0esLvfT>({r?z7CcSPY~XB2xj#VHP8#@i#xAPT~|+c zk@!@TpdZ?_Dq-)PzEM1jS`jB)f7Xz?qkSEu4!IYMDMu(V5$ZDs1(*K3eA~D! z{+ahdr6OVqe`1=-6FS$&5I4tgH#JiDsq+X}2`w_~fUn!?E2-fL$mM-_f)A+5DHW0Ly~XUZ?oxu0p9lxky3{V*{Mf49N#_oVOQoZivz4Eg5z3k_)W oPS)to63=oi+8n-P8)D7Z@nQYVIk7Ju#D}$RV=Mn3;QyNc0l+2}?f?J) literal 0 HcmV?d00001 diff --git a/static/yabin-logo.svg b/static/yabin-logo.svg new file mode 100644 index 0000000..c3ec13f --- /dev/null +++ b/static/yabin-logo.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file