- Server factory with Fastify plugins (JWT, cookie, multipart, formbody, static) - Auth middleware: requireAuth preHandler (401 for API, redirect for pages) - Auth API routes: POST /api/v1/auth/login, POST /api/v1/auth/logout - File API routes: GET/POST /api/v1/files, DELETE /api/v1/files/:id - Page routes: /, /login, /logout, /upload, /files, /files/:id/delete, /f/:id, /f/:id/raw - HTML views: layout, login, upload, file-list, file-view, not-found - CLI register-user script - public/style.css dark theme - Test helpers: createTestApp, loginAs, buildMultipart - Integration tests for auth API, file API, and page routes (51 tests passing) - Update CLAUDE.md with red/green TDD and commit instructions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.0 KiB
1.0 KiB
Nanodrop
Simple file-sharing platform. TypeScript + Fastify + SQLite.
Commands
npm test— Run all tests (vitest)npm run dev— Start dev server (tsx)npm run build— Compile TypeScriptnpm run register-user -- --username <user> --password <pass>— Create user
Architecture
- ESM throughout (
"type": "module") - Fastify with server-rendered HTML pages
- SQLite via better-sqlite3 for persistence
- JWT in httpOnly cookies for auth
- PRG pattern for HTML forms (no client-side JS except copy-to-clipboard)
- Dependency injection — DB/service functions take deps as params for testability
Code Quality
- Review code after every change. Refactor for readability.
- Use strict red/green TDD: write the test first, confirm it FAILS (red), then implement until it passes (green).
- Build and test after every change.
- Break large functions into smaller ones, extract duplicate code.
- Search for duplicated code in tests and extract into reusable helpers.
- Commit after every logical set of changes. Keep commits small and focused.