README.md 5.9 K raw
1
# Sipp
2
3
![cover](https://files.stevedylan.dev/sipp-rust.png)
4
5
Minimal code sharing
6
7
## Features
8
9
- Single binary for web server and TUI
10
- Create snippets and share on the web
11
- Raw output for CLI tools — `curl`, `wget`, and `httpie` get plain text automatically
12
- Interactive TUI with authenticated access for snippet management
13
- Minimal, fast, and low memory consumption
14
15
## Demo
16
17
Try it out at [sipp.so](https://sipp.so) or install and use the TUI
18
19
```bash
20
sipp -r https://sipp.so
21
```
22
23
## Quickstart
24
25
**1. Installo**
26
27
Install the binary from Crates.io
28
29
```bash
30
cargo install sipp-so
31
```
32
33
To confirm it was installed correctly run the following
34
35
```bash
36
sipp --help
37
```
38
39
**2. Start Server**
40
41
For demo purposes you can run this locally, but ideally this would be run in a deployment server with a proper ENV setup with your admin key.
42
43
```bash
44
sipp server --port 3000
45
```
46
47
**3. Create a Snippet**
48
49
You can either open up `http://localhost:3000` and create a snippet in a web browser, or use the TUI. In the same directory, open a new terminal window and use 
50
51
```bash
52
# Path to file
53
sipp path/to/file.rs
54
55
# Or use the interactive tui 
56
sipp
57
```
58
59
## Install
60
61
Sipp can be installed several ways
62
63
### Cargo
64
Install with Cargo directly 
65
66
```bash
67
cargo install sipp-so
68
```
69
70
### GitHub Releases
71
Visit the [releases](https://github.com/stevedylandev/sipp/releases) page and download one of the prebuilt binaries
72
73
## Usage
74
75
### CLI
76
77
```
78
sipp [OPTIONS] [FILE] [COMMAND]
79
```
80
81
#### Commands
82
83
| Command | Description |
84
|---|---|
85
| `server` | Start the web server |
86
| `tui` | Launch the interactive TUI |
87
| `auth` | Save remote URL and API key to config file |
88
89
#### Arguments
90
91
| Argument | Description |
92
|---|---|
93
| `[FILE]` | File path to create a snippet from |
94
95
#### Options
96
97
| Option | Description |
98
|---|---|
99
| `-r, --remote <URL>` | Remote server URL (e.g. `http://localhost:3000`) (env: `SIPP_REMOTE_URL`) |
100
| `-k, --api-key <KEY>` | API key for authenticated operations (env: `SIPP_API_KEY`) |
101
102
### Server
103
104
Sipp includes a built-in web server powered by Axum. Start it with:
105
106
```bash
107
sipp server --port 3000 --host localhost
108
```
109
110
#### Environment Variables
111
112
| Variable | Description |
113
|---|---|
114
| `SIPP_API_KEY` | API key for protecting endpoints |
115
| `SIPP_AUTH_ENDPOINTS` | Comma-separated list of endpoints requiring auth: `api_list`, `api_create`, `api_get`, `api_delete`, `all`, or `none` (defaults to `api_delete,api_list`) |
116
| `SIPP_MAX_CONTENT_SIZE` | Maximum snippet content size in bytes (defaults to `512000` / 500 KB) |
117
| `SIPP_DB_PATH` | Custom path for the SQLite database file (defaults to `sipp.sqlite` in the working directory) |
118
119
The server stores snippets in a local `sipp.sqlite` SQLite database.
120
121
#### API Endpoints
122
123
| Method | Endpoint | Description |
124
|---|---|---|
125
| `GET` | `/api/snippets` | List all snippets |
126
| `POST` | `/api/snippets` | Create a snippet (`{"name": "...", "content": "..."}`) |
127
| `GET` | `/api/snippets/{short_id}` | Get a snippet by ID |
128
| `PUT` | `/api/snippets/{short_id}` | Update a snippet (`{"name": "...", "content": "..."}`) |
129
| `DELETE` | `/api/snippets/{short_id}` | Delete a snippet by ID |
130
131
Authenticated endpoints require an `x-api-key` header.
132
133
#### Raw Output for CLI Tools
134
135
When you access a snippet URL (`/s/{short_id}`) with `curl`, `wget`, or `httpie`, the server returns the raw content as plain text instead of HTML:
136
137
```bash
138
curl https://sipp.so/s/abc123
139
```
140
141
### TUI
142
143
The Sipp TUI makes it easy to create, copy, share, and manage your snippets either locally or remotely. Launch it with:
144
145
```bash
146
# Launch TUI (default behavior when no file argument is given)
147
sipp
148
149
# Or explicitly
150
sipp tui
151
152
# With remote options
153
sipp -r https://sipp.so -k your-api-key
154
```
155
156
#### Local Access
157
158
If you are running `sipp` in the same directory as the `sipp.sqlite` file created by the server instance, the TUI will automatically access the datebase locally and you can edit it directly.
159
160
#### Remote Access
161
162
To access a remote instance of Sipp make sure to do the following:
163
- Set the `SIPP_API_KEY` variable in your server instance
164
- Run `sipp auth` to enter in your server instance URL and the API key, which will be stored under `$HOME/.config/sipp`. You can also set these with the ENV variables `SIPP_REMOTE_URL` and `SIPP_API_KEY`
165
166
>[!NOTE]
167
>You can try a limited remote instance without an API key with `sipp -r https://sipp.so`
168
169
#### Actions
170
171
While inside the TUI the following actions are available
172
173
| Key | Action |
174
|---|---|
175
| `j`/`↓` | Move down / Scroll down |
176
| `k`/`↑` | Move up / Scroll up |
177
| `Enter` | Focus content pane |
178
| `Esc` | Back / Quit |
179
| `y` | Copy snippet content |
180
| `Y` | Copy snippet link |
181
| `o` | Open in browser |
182
| `e` | Edit snippet |
183
| `d` | Delete snippet |
184
| `c` | Create snippet |
185
| `/` | Search snippets |
186
| `r` | Refresh snippets (remote only) |
187
| `q` | Quit |
188
| `?` | Toggle help |
189
190
## Deployment
191
192
Since Sipp is a single binary it can be run in virtually any enviornment.
193
194
### Systemd
195
196
Create a service file at `/etc/systemd/system/sipp.service`:
197
198
```ini
199
[Unit]
200
Description=Sipp snippet server
201
After=network.target
202
203
[Service]
204
ExecStart=/usr/local/bin/sipp server --port 3000 --host 0.0.0.0
205
Environment=SIPP_API_KEY=your-secret-key
206
WorkingDirectory=/var/lib/sipp
207
Restart=on-failure
208
209
[Install]
210
WantedBy=multi-user.target
211
```
212
213
```bash
214
sudo systemctl enable --now sipp
215
```
216
217
### Docker
218
219
A `Dockerfile` and `docker-compose.yml` are included in the repository.
220
221
```bash
222
# Using Docker Compose (recommended)
223
SIPP_API_KEY=your-secret-key docker compose up -d
224
225
# Or build and run manually
226
docker build -t sipp .
227
docker run -p 3000:3000 -e SIPP_API_KEY=your-secret-key -v sipp-data:/data sipp
228
```
229
230
### Railway
231
232
1. Connect your repository to [Railway](https://railway.app)
233
2. Set the environment variables `SIPP_API_KEY` and optionally `SIPP_AUTH_ENDPOINTS`
234
3. Add a [volume](https://docs.railway.com/guides/volumes) to your service and mount it at `/data`
235
4. Set `SIPP_DB_PATH` to `/data/sipp.sqlite` so the database persists across deploys