Performance: Express installation and setup
MEDIUM IMPACT
This affects the initial page load speed and server response time by determining how quickly the Express server can start and handle requests.
const express = require('express'); const app = express(); // Only essential middleware app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(3000, () => console.log('Server started'));
const express = require('express'); const app = express(); // Unnecessary middleware and routes before server start app.use((req, res, next) => { console.log('Middleware 1'); next(); }); app.use((req, res, next) => { console.log('Middleware 2'); next(); }); app.get('/', (req, res) => { res.send('Hello World!'); }); app.listen(3000, () => console.log('Server started'));
| Pattern | Server Startup Time | Middleware Load | Response Delay | Verdict |
|---|---|---|---|---|
| Heavy middleware before routes | High (50-100ms+) | Many | Increased | [X] Bad |
| Minimal middleware with direct routes | Low (few ms) | Few | Minimal | [OK] Good |