simple strings server for the wentworth coding club / my personal use
1# strings
2
3this is a minimal pastebin I designed for Wentworth Institute of Technology's Coding Club
4
5## Features
6
7- Random IDs or custom slugs
8- Syntax highlighting via highlight.js
9- Basic auth for creating pastes
10- Web form at `/new`
11- SQLite storage
12- Single binary via Bun
13- No expiration
14
15## Quick Start
16
17```bash
18# Install deps
19bun install
20
21# Run locally
22AUTH_USERNAME=admin AUTH_PASSWORD=secret bun run dev
23```
24
25Then visit `http://localhost:3000/new` to create your first paste.
26
27## Deploy with NixOS
28
29Add to your flake inputs:
30
31```nix
32{
33 inputs.strings.url = "github:jaspermayone/strings";
34}
35```
36
37Then in your configuration:
38
39```nix
40{ inputs, ... }:
41{
42 imports = [ inputs.strings.nixosModules.default ];
43
44 services.strings = {
45 enable = true;
46 port = 3000;
47 username = "admin";
48 passwordFile = "/run/secrets/strings-password"; # use sops-nix or agenix
49 baseUrl = "https://strings.witcc.dev";
50 };
51
52 # Reverse proxy with nginx
53 services.nginx.virtualHosts."strings.witcc.dev" = {
54 enableACME = true;
55 forceSSL = true;
56 locations."/".proxyPass = "http://127.0.0.1:3000";
57 };
58}
59```
60
61## API
62
63### Create Paste
64
65```bash
66# Plain text with random ID
67curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
68 -H "X-Filename: example.py" \
69 -d 'print("hello")'
70
71# With custom slug
72curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
73 -H "Content-Type: application/json" \
74 -d '{"content": "print(1)", "filename": "test.py", "slug": "my-snippet"}'
75
76# Pipe a file
77cat myfile.rs | curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
78 -H "X-Filename: myfile.rs" \
79 --data-binary @-
80```
81
82Response:
83```json
84{
85 "id": "aBc123xy",
86 "url": "https://strings.witcc.dev/aBc123xy",
87 "raw": "https://strings.witcc.dev/aBc123xy/raw"
88}
89```
90
91### View Paste
92
93```
94GET /{id} # HTML with syntax highlighting
95GET /{id}/raw # Plain text
96```
97
98### Delete Paste
99
100```bash
101curl -u admin:secret -X DELETE https://strings.witcc.dev/aBc123xy
102```
103
104## Web Interface
105
106- `/` - Home page with API docs
107- `/new` - Create paste form (requires auth)
108
109## CLI
110
111Install the CLI:
112
113```bash
114# With Nix
115nix profile install .#cli
116
117# Or just copy the script
118cp cli/strings ~/.local/bin/
119chmod +x ~/.local/bin/strings
120```
121
122Usage:
123
124```bash
125export STRINGS_HOST="https://strings.witcc.dev"
126export STRINGS_USER="admin"
127export STRINGS_PASS="secret"
128
129# Paste a file
130strings myfile.py
131
132# With custom slug
133strings myfile.py --slug my-snippet
134
135# Pipe content
136echo "hello world" | strings
137
138# From clipboard (macOS)
139pbpaste | strings
140```
141
142## Environment Variables
143
144| Variable | Default | Description |
145|----------|---------|-------------|
146| `PORT` | `3000` | HTTP port |
147| `AUTH_USERNAME` | `admin` | Basic auth username |
148| `AUTH_PASSWORD` | `changeme` | Basic auth password |
149| `AUTH_PASSWORD_FILE` | - | Read password from file |
150| `DB_PATH` | `./strings.db` | SQLite database path |
151| `BASE_URL` | `http://localhost:3000` | Public URL (for response) |
152
153## License
154See license.md file.