* docs: regenerate API documentation from src/app/api (329 routes) The generator only recognised `export async function GET`, so every route exported as a guarded const (`export const GET = withAdmin(...)`) or a destructured re-export was missing: the doc listed 116 endpoints, many of them since renamed or removed, against 329 route files today. Teach it the other two export shapes and the withAuth/withAdmin guards, and regenerate both copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: archive dated audits, compliance trackers and migration proposals Moves point-in-time records into docs/archive/ (with a README saying they describe the day they were written): the 2026-01 dev-guide compliance plan, codebase audit, DRY/SSOT and Phase 1 fix logs, the 2026-02 overnight cross-project plan, the 2026-07-02 audit report, the 2026-07-06 Shopware migration plan and system migration strategy, and CODE_AUDIT.md. CODE_AUDIT.md was listed in .claude/CLAUDE.md, .gemini/GEMINI.md and docs/README.md as the current list of issues to fix while its own banner called it a historical snapshot; those entries now point at docs/AUDIT_BACKLOG_2026-08.md, the list of findings still open. docs/README also stops linking api/, legacy/ and reference/, which do not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: archive closed trackers and docs for removed code Into docs/archive/: ARCHITECTURE_DEBT (status CLOSED 2026-06-30), DATABASE_AUDIT (Neon, pre-cutover), UPGRADE_PLAN (2026-06-03 snapshot; Tailwind 4 and React 19 are done), MIGRATION_PLAN_QQQ5 and PROFILES_SSOT_PLAN (both executed: migrations 105 and 121/122), production-ready-checklist (Frauenfeld plan that never shipped), and three docs whose code is gone: PROJECT_PAGES_GUIDE (src/components/projects and the per-project pages, now one [slug] route), RevampCopilot (no src/features/chatbot) and projects/upcycling (the /projects/upcycling pages and businessPlan messages are no longer in the tree). Inbound references follow the move, including three code comments. SHARED_CONTEXT and COMMANDS stop describing the upcycling mini-site as live; COMMANDS drops db:migrate-users, which is not a script. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: correct live docs against the tree - BLOG_SYSTEM: rewritten from the code. There is no TinaCMS and no content/submissions; posts merge content/posts/*.md with blog_posts, and submissions are blog_submissions rows reviewed by staff. - installation guide: rewritten. There is no cms-api, no docker-compose.dev.yml and no default admin password; setup is services:up, db:migrate, setup-admins, dev. - RELIABILITY: migration 005b (not 005), no ENABLE_CMS gate, prod facts. - RESPONSIVE_DESIGN_SYSTEM: ResponsiveSection/Hero/Heading were removed; document Section, PageHero and Heading instead. - DEAD_CODE: the /api/repairers and /api/it-hilfe/helpers proxies and the routes.helpers alias are deleted, not 410; fix a stale line range. - DEV_GUIDE, AGENTS, claude/cursor/gemini guides, .cursorrules: DEVELOPMENT_GUIDELINES.md never existed here; protected files are in .claude/CLAUDE.md. src/config/site.ts -> org.ts/urls.ts; Next.js 16. - src/middleware.ts -> src/proxy.ts; components/ui/Button.tsx -> src/components/ui/button.tsx; reference page paths. - docs-paths baseline 68 -> 6, as the check asks when the count falls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD * docs: fix dead links in package and example READMEs ai-native-cms-core linked a Next.js plugin, a CLI and docs/quick-start.md that do not exist in this repo; ai-native-cms-react has no README; the saldo README pointed at the repo root instead of the implementation in src/lib/team/saldo.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJkbo18cRNXtgPWZN2S9cD --------- Co-authored-by: Claude <noreply@anthropic.com>
8.5 KiB
created_date, last_modified_date, last_modified_summary
| created_date | last_modified_date | last_modified_summary |
|---|---|---|
| 2026-01-30 | 2026-01-30 | Initial summary of Phase 1 fixes applied |
Phase 1 Fixes Applied
Summary of critical violations fixed from codebase audit
Reference: See
docs/development/CODEBASE_AUDIT.mdfor full audit details
Infrastructure Created
✅ 1. API Helper Functions (src/lib/api/helpers.ts)
Created standardized API response helpers:
apiSuccess<T>(data, status)- Standardized success responsesapiError(error, message, status)- Standardized error responses with loggingapiNotFound(resource)- 404 responsesapiUnauthorized(message)- 401 responsesapiForbidden(message)- 403 responsesapiBadRequest(message, errors?)- 400 responses with optional validation errors
Benefits:
- Consistent API response format across all routes
- Automatic error logging
- Type-safe responses
✅ 2. API Middleware (src/lib/api/middleware.ts)
Created reusable middleware:
withAuth(handler)- Automatic authentication checkwithAdmin(handler)- Authentication + admin role check
Benefits:
- DRY principle - no duplicate auth checks
- Consistent error handling
- Type-safe session passing
✅ 3. Database Configuration (src/config/database.ts)
Created Single Source of Truth for table names:
TABLE_NAMESconstant with all table names- Type-safe table name references
Benefits:
- No hardcoded table names
- Easy refactoring
- Compile-time safety
✅ 4. Shop Configuration (src/config/shop.ts)
Created centralized shop config:
SHOP_CONFIGwith backend URL, publishable key- Environment variable validation
Benefits:
- No hardcoded API keys
- Centralized configuration
- Security improvement
Files Fixed
✅ Critical Security Fixes
-
src/app/api/shop/products/route.ts- ❌ Removed hardcoded publishable key
- ❌ Replaced 2x
console.errorwithlogger.error - ✅ Now uses
SHOP_CONFIGandapiError/apiSuccess
-
src/app/api/admin/products/route.ts- ❌ Removed hardcoded publishable key (with fallback)
- ❌ Replaced 4x
console.errorwithlogger.error - ✅ Now uses
SHOP_CONFIGand standardized helpers - ✅ Both GET and POST methods fixed
✅ Error Handling Standardization
-
src/app/api/messages/[conversationId]/route.ts- ❌ Replaced 2x
console.errorwithlogger.error - ❌ Replaced inconsistent error responses
- ✅ Now uses
apiError,apiSuccess,apiNotFound,apiUnauthorized - ✅ Uses
TABLE_NAMESconstants for table names
- ❌ Replaced 2x
-
src/app/api/auth/register/route.ts- ❌ Replaced
console.errorwithlogger.error - ❌ Replaced inconsistent error responses
- ✅ Now uses
apiError,apiSuccess,apiBadRequest
- ❌ Replaced
-
src/app/api/appointments/route.ts- ❌ Replaced 2x
console.errorwithlogger.error - ❌ Replaced inconsistent error responses
- ✅ Now uses standardized helpers
- ✅ Uses
TABLE_NAMESconstants - ✅ Both GET and POST methods fixed
- ❌ Replaced 2x
-
src/app/api/ai/analyze-product/route.ts- ❌ Fixed
anytype incalculateSustainabilityScorefunction - ❌ Replaced
console.errorwithlogger.error - ❌ Replaced inconsistent error responses
- ✅ Added
ProductDatainterface - ✅ Now uses
apiError,apiSuccess,apiBadRequest
- ❌ Fixed
✅ DRY/SSOT Violations Fixed
-
src/app/api/repairer/apply/route.ts- ❌ Removed duplicate auth check
- ❌ Replaced hardcoded error messages with
ERROR_MESSAGES - ❌ Replaced hardcoded table names with
TABLE_NAMES - ❌ Replaced
console.errorwithlogger.error - ✅ Uses standardized helpers and config
-
src/app/api/seller/apply/route.ts- ❌ Removed duplicate auth check
- ❌ Removed duplicate application status check
- ❌ Replaced hardcoded error messages with
ERROR_MESSAGES - ❌ Replaced hardcoded table names with
TABLE_NAMES - ❌ Replaced
console.errorwithlogger.error - ✅ Uses standardized helpers and config
-
src/app/api/seller/products/route.ts- ❌ Removed duplicate auth check
- ❌ Removed duplicate seller role check (now uses
requireSeller()) - ❌ Replaced hardcoded error messages with
ERROR_MESSAGES - ❌ Replaced hardcoded table names with
TABLE_NAMES - ❌ Removed hardcoded shop URL and API key
- ❌ Replaced 3x
console.*withlogger.* - ✅ Uses standardized helpers, config, and role checks
-
src/app/api/user/profile/route.ts- ❌ Removed duplicate auth checks (2x)
- ❌ Fixed
anytype in PUT handler - ❌ Replaced
console.errorwithlogger.error - ❌ Replaced inconsistent error responses
- ✅ Uses standardized helpers and proper types
-
src/app/api/messages/conversations/route.ts- ❌ Removed duplicate auth checks (2x)
- ❌ Replaced hardcoded error messages with
ERROR_MESSAGES - ❌ Replaced hardcoded table names with
TABLE_NAMES - ❌ Replaced 2x
console.errorwithlogger.error - ✅ Uses standardized helpers and config
- ✅ Both GET and POST methods fixed
-
src/app/api/workshops/registration/[instanceId]/route.ts- ❌ Replaced
console.errorwithlogger.error - ❌ Replaced hardcoded error messages with
ERROR_MESSAGES - ❌ Replaced hardcoded table names with
TABLE_NAMES - ✅ Uses standardized helpers and config
- ❌ Replaced
Statistics
Fixed Violations
| Category | Before | After | Fixed |
|---|---|---|---|
| Hardcoded API keys | 2 files | 0 files | ✅ 100% |
| console.log in API routes | ~35 instances | 0 instances | ✅ 100% (in fixed files) |
| Inconsistent error handling | ~12 routes | 0 routes | ✅ 100% (in fixed files) |
| Hardcoded table names (SQL) | 9+ files | 0 files | ✅ 100% (in fixed files) |
| Hardcoded error messages | 39+ instances | 0 instances | ✅ 100% (in fixed files) |
| Duplicate auth checks | 17 files | 0 files | ✅ 100% (in fixed files) |
| Duplicate role checks | 3+ files | 0 files | ✅ 100% (in fixed files) |
any types in API routes |
2 functions | 0 functions | ✅ 100% (in fixed files) |
Files Created
- ✅
src/lib/api/helpers.ts- API response helpers - ✅
src/lib/api/middleware.ts- API middleware - ✅
src/lib/api/role-checks.ts- Role checking utilities (DRY) - ✅
src/config/database.ts- Database table names (SSOT) - ✅
src/config/shop.ts- Shop configuration (SSOT) - ✅
src/config/error-messages.ts- Error messages (SSOT)
Files Fixed
Critical Security & Quality (6 files):
- ✅
src/app/api/shop/products/route.ts - ✅
src/app/api/admin/products/route.ts - ✅
src/app/api/messages/[conversationId]/route.ts - ✅
src/app/api/auth/register/route.ts - ✅
src/app/api/appointments/route.ts - ✅
src/app/api/ai/analyze-product/route.ts
DRY/SSOT Violations (6 files):
- ✅
src/app/api/repairer/apply/route.ts - ✅
src/app/api/seller/apply/route.ts - ✅
src/app/api/seller/products/route.ts - ✅
src/app/api/user/profile/route.ts - ✅
src/app/api/messages/conversations/route.ts - ✅
src/app/api/workshops/registration/[instanceId]/route.ts
Remaining Work
Phase 1 Remaining (Critical)
Still need to fix:
- ~49 more files with
console.logstatements (84 total - 35 fixed = 49 remaining) - ~30 more files with
anytypes (32 total - 2 fixed = 30 remaining)
Phase 2 (High Priority)
- Standardize error handling in remaining ~38 API routes (50 total - 12 fixed = 38 remaining)
- Extract duplicate auth patterns using standardized pattern
- Move more hardcoded values to config
- Fix remaining duplicate patterns using established helpers
Phase 3 (Medium Priority)
- Remove TypeScript suppressions (2 files)
- Standardize response formats in remaining routes
Next Steps
- Continue Phase 1: Fix remaining
console.login API routes - Apply middleware: Refactor routes to use
withAuthmiddleware - Fix
anytypes: Create proper interfaces for remaining files - Update documentation: Update API documentation with new patterns
Notes
- All fixes follow
docs/development/DEV_GUIDE.mdpatterns - All fixes maintain backward compatibility
- No breaking changes to API responses (format improved, not changed)
- Linter checks passed for all fixed files
Last Updated: 2026-01-30
Status: Phase 1 & 2 complete (12 files fixed, infrastructure created, DRY/SSOT violations addressed)
See Also: docs/development/DRY_SSOT_FIXES.md for detailed DRY/SSOT refactoring summary