Performance: GET route handling
MEDIUM IMPACT
This affects server response time and how quickly the browser receives content to start rendering.
app.get('/data', async (req, res) => { // asynchronous processing or cached result const result = await getCachedResult(); res.send(`Result is ${result}`); });
app.get('/data', (req, res) => { // heavy synchronous processing let result = 0; for(let i = 0; i < 1e8; i++) { result += i; } res.send(`Result is ${result}`); });
| Pattern | Server Blocking | Response Delay | Security Risk | Verdict |
|---|---|---|---|---|
| Synchronous heavy processing in GET route | Blocks event loop | High delay (100+ ms) | Low | [X] Bad |
| Asynchronous or cached response in GET route | Non-blocking | Low delay (<10 ms) | Low | [OK] Good |
| Unparameterized DB query in GET route | Blocks event loop | Medium delay (50+ ms) | High | [X] Bad |
| Parameterized async DB query in GET route | Non-blocking | Low delay (<20 ms) | Low | [OK] Good |