Skip to content

Commit

Permalink
We are at v1.0.0!
Browse files Browse the repository at this point in the history
  • Loading branch information
Yureien committed Jun 13, 2023
1 parent 7e3bbbf commit 6857914
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 20 deletions.
62 changes: 62 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
@@ -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 |
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)**
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yabin",
"version": "0.0.1",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
2 changes: 1 addition & 1 deletion src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;700&family=Fira+Mono&display=swap"
rel="stylesheet">
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<link rel="icon" href="yabin-logo.ico" />
<meta name="viewport" content="width=device-width" />
<title>YABin</title>
%sveltekit.head%
Expand Down
12 changes: 6 additions & 6 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
@@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/routes/api/paste/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});

Expand Down
25 changes: 18 additions & 7 deletions src/routes/info/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,25 @@
href="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/Yureien/YABin">open-source</a
> and easily self-hostable.
</li>
<li>It can even be run in serverless environments!</li>
</ul>

<p class="mt-4">
The API documentation is available <a
class="underline underline-offset-2"
href="https://github.com/Yureien/YABin/blob/main/API.md">here</a
>.
</p>
</div>

<div class="mt-8">
<h1 class="text-4xl">Support the development</h1>
<p class="text-lg mt-2">
<p class="mt-2">
If you really like this project, I'd love it if you <a
href="https://ko-fi.com/A0A21C34E"
target="_blank"
><img
class="border-0 inline h-10"
class="border-0 inline h-8"
src="https://storage.ko-fi.com/cdn/kofi3.png?v=3"
alt="Buy Me a Coffee at ko-fi.com"
/></a
Expand All @@ -107,13 +115,16 @@
<iframe
src="https://github.com/sponsors/Yureien/button"
title="Sponsor Yureien"
class="border-0 rounded h-10 inline w-32"
class="border-0 rounded h-8 inline w-28"
/> me on GitHub.
</p>
<p class="text-lg mt-4">
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!
<p class="text mt-4">
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 <a
class="underline underline-offset-2"
href="mailto:[email protected]">[email protected]</a
>, and I will get back to you as soon as possible.
</p>
</div>
</div>
Expand Down
Binary file added static/yabin-logo.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions static/yabin-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6857914

Please sign in to comment.