Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jaspermayone/strings

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

simple strings server for the wentworth coding club / my personal use

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.