Severity: Low
Category: Performance
Description
In api/src/routes/product.ts, all by-ID lookups use Array.find() / Array.findIndex() which is O(n). Not critical for the current in-memory demo, but a Map<number, Product> would provide O(1) lookups if the dataset grows.
Suggested Fix
Use a Map for product storage indexed by productId:
const productMap = new Map<number, Product>();
seedProducts.forEach(p => productMap.set(p.productId, p));
Affected File
api/src/routes/product.ts (GET/:id, PUT/:id, DELETE/:id handlers)
Severity: Low
Category: Performance
Description
In
api/src/routes/product.ts, all by-ID lookups useArray.find()/Array.findIndex()which is O(n). Not critical for the current in-memory demo, but aMap<number, Product>would provide O(1) lookups if the dataset grows.Suggested Fix
Use a
Mapfor product storage indexed byproductId:Affected File
api/src/routes/product.ts(GET/:id, PUT/:id, DELETE/:id handlers)