1.9 KiB
1.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
A minimal, self-contained image upload server written in vanilla Node.js (ES modules). No external dependencies — only Node.js built-ins (http, fs, path, url).
Running the Server
# Direct
node server.mjs
# Via daemon manager
./server.sh start
./server.sh stop
./server.sh restart
./server.sh status
- Listens on
0.0.0.0:8765(hardcoded inserver.mjs) - Logs to
/tmp/server_mjs.log; PID tracked at/tmp/server_mjs.pid
Architecture
The entire application lives in two files:
server.mjs — Three logical sections:
- Embedded HTML UI (lines 9–85): Full self-contained frontend (HTML/CSS/JS) as a string constant — no separate asset files. Dark theme, drag-and-drop, German labels.
parseMultipart()(lines 87–110): Custom binary multipart/form-data parser; no external library.- HTTP server (lines 112–145): Two routes —
GET /serves the UI,POST /uploadsaves files to the directory whereserver.mjslives.
server.sh — Daemon management (start/stop/restart/status). Note: the path inside the script points to /home/joachim/git/ai-coding-kit/screens/server.mjs, not the local copy — update if deploying from this directory.
Key Conventions
- Save location: Files are written to the same directory as
server.mjsviafileURLToPath(import.meta.url). - Filename sanitization:
path.basename()prevents path traversal; regex/[^a-zA-Z0-9._\- ()äöüÄÖÜß]/greplaces disallowed characters with underscores. German characters are intentionally allowed. - Synchronous writes:
fs.writeFileSync()is used deliberately for simplicity. - UI is embedded: Keep HTML/CSS/JS inside the string constant in
server.mjs— there are no separate asset files by design.