Files
claude-code-screenshots/CLAUDE.md
2026-04-13 09:11:52 +00:00

42 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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
```bash
# 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 in `server.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:
1. **Embedded HTML UI** (lines 985): Full self-contained frontend (HTML/CSS/JS) as a string constant — no separate asset files. Dark theme, drag-and-drop, German labels.
2. **`parseMultipart()`** (lines 87110): Custom binary multipart/form-data parser; no external library.
3. **HTTP server** (lines 112145): Two routes — `GET /` serves the UI, `POST /upload` saves files to the directory where `server.mjs` lives.
**`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.mjs` via `fileURLToPath(import.meta.url)`.
- **Filename sanitization**: `path.basename()` prevents path traversal; regex `/[^a-zA-Z0-9._\- ()äöüÄÖÜß]/g`replaces 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.