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 fileTake it
12345678910111213141516171819202122232425import express from 'express'import type { RouterInterface } from './tool.mts'import { routes, handler } from './tool.mts'
const router = express.Router()const name = 'express (WARNING: includes handling)'
for (const route of routes) { // path-to-regexp v8 (express 5) requires named wildcards const path = route.path.replace(/\/\*$/, '/*splat') if (route.method === 'GET') { router.route(path).get(handler) } else { router.route(path).post(handler) }}
export const expressRouter: RouterInterface = { name, match: (route) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any ;(router as any).handle({ method: route.method, url: route.path }, {}, () => {}) },}