# TimeClock Backend API v3.0 Node.js/Express Backend für die TimeClock Zeiterfassungsanwendung. ## Installation ```bash npm install ``` ## Konfiguration Erstellen Sie eine `.env` Datei im Backend-Verzeichnis: ```env PORT=3000 NODE_ENV=development ``` ## Starten ### Entwicklung (mit Auto-Reload) ```bash npm run dev ``` ### Produktion ```bash npm start ``` ## API-Dokumentation ### Base URL ``` http://localhost:3010/api ``` ### Endpunkte #### Health Check ``` GET /api/health ``` **Response:** ```json { "status": "ok", "message": "TimeClock API v3.0.0", "timestamp": "2025-10-15T10:00:00.000Z" } ``` #### Alle Zeiteinträge abrufen ``` GET /api/time-entries ``` #### Einzelnen Zeiteintrag abrufen ``` GET /api/time-entries/:id ``` #### Neuen Zeiteintrag erstellen ``` POST /api/time-entries Content-Type: application/json { "project": "Mein Projekt", "description": "Beschreibung" } ``` #### Zeiteintrag aktualisieren ``` PUT /api/time-entries/:id Content-Type: application/json { "endTime": "2025-10-15T10:30:00.000Z", "description": "Aktualisierte Beschreibung" } ``` #### Zeiteintrag löschen ``` DELETE /api/time-entries/:id ``` #### Statistiken abrufen ``` GET /api/time-entries/stats/summary ``` **Response:** ```json { "totalEntries": 10, "completedEntries": 8, "runningEntries": 2, "totalHours": "42.50", "totalSeconds": 153000, "projectStats": { "Projekt A": { "duration": 86400, "count": 5 } } } ``` ## Datenmodell ### TimeEntry ```javascript { id: Number, startTime: String (ISO 8601), endTime: String (ISO 8601) | null, description: String, project: String, duration: Number (Sekunden) | null, isRunning: Boolean } ``` ## Dependencies - **express** - Web-Framework - **cors** - CORS-Middleware - **helmet** - Sicherheits-Middleware - **morgan** - HTTP Request Logger - **dotenv** - Environment Variables ## Entwicklung Der aktuelle Stand verwendet In-Memory-Speicher. Für eine Produktionsumgebung sollte eine Datenbank integriert werden: - MongoDB mit mongoose - PostgreSQL mit pg/sequelize - MySQL mit mysql2/sequelize