simple strings server for the wentworth coding club / my personal use
TypeScript 72.1%
Nix 22.8%
Shell 5.1%
11 1 0

Clone this repository

https://tangled.org/jaspermayone.com/strings https://tangled.org/did:plc:abgthiqrd7tczkafjm4ennbo/strings
git@knot.jaspermayone.com:jaspermayone.com/strings git@knot.jaspermayone.com:did:plc:abgthiqrd7tczkafjm4ennbo/strings

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

strings#

this is a minimal pastebin I designed for Wentworth Institute of Technology's Coding Club

Features#

  • Random IDs or custom slugs
  • Syntax highlighting via highlight.js
  • Basic auth for creating pastes
  • Web form at /new
  • SQLite storage
  • Single binary via Bun
  • No expiration

Quick Start#

# Install deps
bun install

# Run locally
AUTH_USERNAME=admin AUTH_PASSWORD=secret bun run dev

Then visit http://localhost:3000/new to create your first paste.

Deploy with NixOS#

Add to your flake inputs:

{
  inputs.strings.url = "github:jaspermayone/strings";
}

Then in your configuration:

{ inputs, ... }:
{
  imports = [ inputs.strings.nixosModules.default ];

  services.strings = {
    enable = true;
    port = 3000;
    username = "admin";
    passwordFile = "/run/secrets/strings-password"; # use sops-nix or agenix
    baseUrl = "https://strings.witcc.dev";
  };

  # Reverse proxy with nginx
  services.nginx.virtualHosts."strings.witcc.dev" = {
    enableACME = true;
    forceSSL = true;
    locations."/".proxyPass = "http://127.0.0.1:3000";
  };
}

API#

Create Paste#

# Plain text with random ID
curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
  -H "X-Filename: example.py" \
  -d 'print("hello")'

# With custom slug
curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
  -H "Content-Type: application/json" \
  -d '{"content": "print(1)", "filename": "test.py", "slug": "my-snippet"}'

# Pipe a file
cat myfile.rs | curl -u admin:secret -X POST https://strings.witcc.dev/api/paste \
  -H "X-Filename: myfile.rs" \
  --data-binary @-

Response:

{
  "id": "aBc123xy",
  "url": "https://strings.witcc.dev/aBc123xy",
  "raw": "https://strings.witcc.dev/aBc123xy/raw"
}

View Paste#

GET /{id}      # HTML with syntax highlighting
GET /{id}/raw  # Plain text

Delete Paste#

curl -u admin:secret -X DELETE https://strings.witcc.dev/aBc123xy

Web Interface#

  • / - Home page with API docs
  • /new - Create paste form (requires auth)

CLI#

Install the CLI:

# With Nix
nix profile install .#cli

# Or just copy the script
cp cli/strings ~/.local/bin/
chmod +x ~/.local/bin/strings

Usage:

export STRINGS_HOST="https://strings.witcc.dev"
export STRINGS_USER="admin"
export STRINGS_PASS="secret"

# Paste a file
strings myfile.py

# With custom slug
strings myfile.py --slug my-snippet

# Pipe content
echo "hello world" | strings

# From clipboard (macOS)
pbpaste | strings

Environment Variables#

Variable Default Description
PORT 3000 HTTP port
AUTH_USERNAME admin Basic auth username
AUTH_PASSWORD changeme Basic auth password
AUTH_PASSWORD_FILE - Read password from file
DB_PATH ./strings.db SQLite database path
BASE_URL http://localhost:3000 Public URL (for response)

License#

See license.md file.