Skip to content

Commit 6bf9813

Browse files
authored
Update Express to v5.0.0 and fix route parameter compatibility (#16)
- Update Express dependency from ^4.19.2 to ^5.0.0 - Replace optional route parameter syntax (:count?) with separate routes for Express v5 compatibility - Refactor batch endpoint to use handleBatchRequest helper function - Add dedicated routes for /batch/:type/:count and /batch/:type - All tests passing with Express v5
1 parent 3edf58a commit 6bf9813

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

examples/express-benchmark-app.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ app.get('/mixed', (req, res) => {
294294
}
295295
})
296296

297-
// Batch endpoint - runs multiple operations of the same type
298-
app.get('/batch/:type/:count?', (req, res) => {
297+
// Helper function for batch processing
298+
function handleBatchRequest (req, res) {
299299
const { type, count = 5 } = req.params
300300
const batchCount = Math.min(Math.max(parseInt(count), 1), 20) // Limit between 1-20
301301

@@ -350,7 +350,13 @@ app.get('/batch/:type/:count?', (req, res) => {
350350
timestamp: new Date().toISOString()
351351
})
352352
}
353-
})
353+
}
354+
355+
// Batch endpoint - runs multiple operations of the same type (with count)
356+
app.get('/batch/:type/:count', handleBatchRequest)
357+
358+
// Batch endpoint - runs multiple operations of the same type (default count)
359+
app.get('/batch/:type', handleBatchRequest)
354360

355361
// Root endpoint - provides API documentation
356362
app.get('/', (req, res) => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"compression": "^1.7.4",
5151
"cors": "^2.8.5",
5252
"eslint": "^9.0.0",
53-
"express": "^4.19.2",
53+
"express": "^5.0.0",
5454
"helmet": "^8.0.0",
5555
"light-my-request": "^6.6.0",
5656
"morgan": "^1.10.0",

0 commit comments

Comments
 (0)