photos/src/app/api/stats/route.ts
Michael Mainguy 31784d91b2 Add SQLite database and directory management system
- Install better-sqlite3 for embedded SQLite support
- Create complete database schema with photos, albums, tags, directories tables
- Add PhotoService class with full CRUD operations and relationships
- Create comprehensive API endpoints for photos, albums, directories, and stats
- Add DirectoryList component with delete functionality and visual feedback
- Implement directory saving to database when user selects path
- Add automatic refresh of directory list when new directories are saved
- Update Button component with enhanced enabled/disabled states and animations
- Add Tab key handling to hide suggestions in directory modal
- Update .gitignore to exclude SQLite database files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 14:26:55 -05:00

27 lines
806 B
TypeScript

import { NextResponse } from 'next/server'
import { photoService } from '@/lib/photo-service'
export async function GET() {
try {
const photoCount = photoService.getPhotoCount()
const totalSize = photoService.getTotalFileSize()
const directories = photoService.getDirectories()
const albums = photoService.getAlbums()
const tags = photoService.getTags()
return NextResponse.json({
photoCount,
totalSize,
directoryCount: directories.length,
albumCount: albums.length,
tagCount: tags.length,
directories: directories.slice(0, 5) // Latest 5 directories
})
} catch (error) {
console.error('Error fetching stats:', error)
return NextResponse.json(
{ error: 'Failed to fetch statistics' },
{ status: 500 }
)
}
}