Skip to content
Myr

express.mts

This file

Path

benchmarks/routers/src/express.mts

24 lines · 715 bytes · TypeScript

Last changed by

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

History of this file

Take it

The walk stopped after 200 commits: lines older than 83bfb3b point at it.

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

line 1why, one step back
1import express from 'express'

4.12.23Yusuke Wadabefore adoption83bfb3b

lines 2–4why, one step back
2import type { RouterInterface } from './tool.mts'
3import { routes, handler } from './tool.mts'4

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

line 5why, one step back
5const router = express.Router()

4.12.23Yusuke Wadabefore adoption83bfb3b

lines 6–8why, one step back
6const name = 'express (WARNING: includes handling)'
78for (const route of routes) {

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

lines 9–10why, one step back
9 // path-to-regexp v8 (express 5) requires named wildcards
10 const path = route.path.replace(/\/\*$/, '/*splat')

4.12.23Yusuke Wadabefore adoption83bfb3b

line 11why, one step back
11 if (route.method === 'GET') {

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

line 12why, one step back
12 router.route(path).get(handler)

4.12.23Yusuke Wadabefore adoption83bfb3b

line 13why, one step back
13 } else {

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

line 14why, one step back
14 router.route(path).post(handler)

4.12.23Yusuke Wadabefore adoption83bfb3b

lines 15–20why, one step back
15 }
16}1718export const expressRouter: RouterInterface = {19 name,20 match: (route) => {

chore(benchmark/routers): bump deps (#5107)Yusuke Wadabefore adoption29a3f73

lines 21–22why, one step back
21 // eslint-disable-next-line @typescript-eslint/no-explicit-any
22 ;(router as any).handle({ method: route.method, url: route.path }, {}, () => {})

4.12.23Yusuke Wadabefore adoption83bfb3b

lines 23–24why, one step back
23 },
24}