Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlcarveth/nutty
A very simple HTTP server, and a paste server implementation.
https://github.com/jlcarveth/nutty
deno http-server pastebin plaintext
Last synced: about 6 hours ago
JSON representation
A very simple HTTP server, and a paste server implementation.
- Host: GitHub
- URL: https://github.com/jlcarveth/nutty
- Owner: JLCarveth
- License: mit
- Created: 2023-03-14T20:08:41.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-26T19:19:18.000Z (7 months ago)
- Last Synced: 2024-12-06T17:22:13.433Z (about 1 month ago)
- Topics: deno, http-server, pastebin, plaintext
- Language: TypeScript
- Homepage: https://paste.jlcarveth.dev
- Size: 138 KB
- Stars: 60
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Nutty
#### A simple HTTP paste server - Contributions Welcome!Nutty is a self-hostable paste server, allowing you to easily upload and share text files instantly.
## Features
- A simple HTTP interface
- A simple Web interface (WIP)
- Public and private pastes
- [Low memory footprint](https://github.com/JLCarveth/nutty/assets/23156861/b449813a-719a-4c9b-8922-f91f70101b1d)
- Burn-on-read - Pastes that can only be read once
- Automatic Syntax Highlighting## Installation
1. Make sure you have Deno installed on your system. If not, you can install it by following the instructions on the [Deno website](https://deno.land/#installation).
2. Clone the repository by running `git clone https://github.com/JLCarveth/nutty.git`.
3. Change into the cloned directory by running `cd nutty`.
4. Run the `paste.ts` file with Deno by running `deno run -A --unstable paste.ts`.A simple systemd service can also be setup to handle stopping/starting Nutty:
```Systemd
[Unit]
Description=File pasting API[Service]
ExecStart=/home/jlcarveth/.deno/bin/deno run -A --unstable paste.ts
Restart=always
User=jlcarveth
Group=jlcarveth
WorkingDirectory=/opt/paste
EnvironmentFile=/opt/paste/.env
StandardOutput=journal
StandardError=journal[Install]
WantedBy=multi-user.target
```
### Environment
Nutty depends on a couple of environment variables to be established before running.
|Variable Name|Description|Example Values|
|---|---|---|
|`TARGET_DIR`|The directory where pastes will be stored.|`/opt/paste/data`|
|`BASE_URL`|The base URL at which the API can be accessed.|`https://paste.mysite.com/api`|
|`SECRET_KEY`|Used for signing JWTs. A secret key can be generated with `openssl rand -base64 32`|`GDZ1FzBF18dtAk2enanqqxskVf5hptmPjy/pcBm384M=`|
|`PORT`|The port to listen to. Default is 5335|`5335`|
|`PUBLIC_PASTES`|Whether to allow users to create pastes without an access token.|1,0,true,false|
|`DEBUG`|Logs incoming requests for debugging purposes.|1,0,true,false|
|`DOMAIN`|The domain used for the HTTP cookie, as well as the burn URLs. |`paste.jlcarveth.dev`|## Usage
There is a simple client bash script which provides a simple example of using Nutty.
```
export TOKEN=$(curl https://paste.jlcarveth.dev/api/login -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]","password":"notmypassword"}')
export EMAIL="[email protected]" # Email is used for signing PGP messages
uuid=$(cat file.txt | bash client.sh)
```
If the client runs successfully, a UUID associated with the new paste is returned. This paste can then be retrieved with a simple GET request:
```
curl $API_URL/$UUID -H "X-Access-Token: $TOKEN"
```