Performance: Documenting endpoints
MEDIUM IMPACT
This affects the server response time and client load speed by adding metadata and documentation overhead.
const swaggerDoc = require('./swagger.json'); const swaggerUi = require('swagger-ui-express'); // Serve docs separately app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDoc)); app.get('/api/data', (req, res) => { const data = fetchData(); res.json(data); });
app.get('/api/data', (req, res) => { // heavy inline documentation strings /** * This endpoint returns data with detailed explanation... * Lots of comments and examples inside the handler */ const data = fetchData(); res.json(data); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline documentation in handlers | N/A | N/A | N/A | [X] Bad |
| Separate static docs route | N/A | N/A | N/A | [OK] Good |