perf: optimize drawings endpoint with caching and lazy loading
- Add 5s in-memory cache for /drawings responses with automatic cleanup - Split Drawing/DrawingSummary types for efficient data fetching - Implement lazy loading of drawing data in DrawingCard component - Add configurable DRAWINGS_CACHE_TTL_MS and RATE_LIMIT_MAX_REQUESTS env vars - Prevent memory leaks with periodic cleanup of cache and rate limit maps - Add loading states and better UX for export operations - Improve JSON parsing with error handling for malformed stored data Benchmark results (100 drawings, cached): - Avg latency: 6.94ms (p50: 4ms, p97.5: 8ms) - Avg throughput: 668 req/s (peak: 1,023) - 3k requests in 5s with 0 errors Update .gitignore to exclude generated files, env files, and build artifacts
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
export interface Drawing {
|
||||
export interface DrawingSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
elements: any[];
|
||||
appState: any;
|
||||
files: Record<string, any> | null;
|
||||
collectionId: string | null;
|
||||
updatedAt: number;
|
||||
createdAt: number;
|
||||
preview?: string;
|
||||
version: number;
|
||||
preview?: string | null;
|
||||
}
|
||||
|
||||
export interface Drawing extends DrawingSummary {
|
||||
elements: any[];
|
||||
appState: any;
|
||||
files: Record<string, any> | null;
|
||||
}
|
||||
|
||||
export interface Collection {
|
||||
|
||||
Reference in New Issue
Block a user