Performance: Response handling
MEDIUM IMPACT
Response handling affects how quickly the server sends data back to the client, impacting page load speed and interaction responsiveness.
async getData() { const data = await this.service.fetchData(); return data; // Let NestJS handle JSON serialization }
async getData() { const data = await this.service.fetchData(); return JSON.stringify(data); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual JSON.stringify in response | 0 | 0 | 0 | [X] Bad |
| Returning object for NestJS to serialize | 0 | 0 | 0 | [OK] Good |
| Loading full file buffer before sending | 0 | 0 | 0 | [X] Bad |
| Streaming file response | 0 | 0 | 0 | [OK] Good |
| Manual header setting in method | 0 | 0 | 0 | [X] Bad |
| Using @Header decorators | 0 | 0 | 0 | [OK] Good |