{"id":18342,"library":"express-match-request","title":"express-match-request","description":"Express middleware for matching incoming requests (method + URL) to a pattern, commonly used to conditionally apply further middleware or route handlers. Latest version 0.1.3, released sporadically. Minimal utility with no dependencies; relies on Express's req.method and req.originalUrl for pattern matching. Not actively maintained, with only a few releases. Simpler than full-featured route-matching libraries like express-path-match or find-my-way, but may not support advanced patterns or wildcards.","status":"maintenance","version":"0.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/webextensions/express-match-request","tags":["javascript","express","middleware","match","request","originalUrl"],"install":[{"cmd":"npm install express-match-request","lang":"bash","label":"npm"},{"cmd":"yarn add express-match-request","lang":"bash","label":"yarn"},{"cmd":"pnpm add express-match-request","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; designed as Express middleware","package":"express","optional":false}],"imports":[{"note":"Package exports a single function as default export. CommonJS users must use require('express-match-request').default or assign to a default import.","wrong":"const { matchRequest } = require('express-match-request')","symbol":"default","correct":"import matchRequest from 'express-match-request'"},{"note":"CommonJS require returns the default export directly as a function.","wrong":"import { matchRequest } from 'express-match-request'","symbol":"matchRequest","correct":"const matchRequest = require('express-match-request')"},{"note":"No named exports; only a default function. No type definitions provided.","wrong":null,"symbol":"Pattern","correct":"import matchRequest from 'express-match-request'"}],"quickstart":{"code":"import express from 'express';\nimport matchRequest from 'express-match-request';\n\nconst app = express();\n\n// Match requests to GET /api/users\napp.use(matchRequest('GET', '/api/users'), (req, res) => {\n  res.json({ message: 'Users endpoint' });\n});\n\n// Match all methods to /public\napp.use(matchRequest('*', '/public'), express.static('public'));\n\napp.listen(3000, () => console.log('Server running on port 3000'));","lang":"javascript","description":"Demonstrates using matchRequest as middleware to conditionally handle GET /api/users and serve static files on /public."},"warnings":[{"fix":"Use a library like express-path-match for parameterized routes.","message":"Pattern matching is simple equality, not RegExp or path-to-regexp. Complex patterns (e.g., '/users/:id') will not work as expected.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider alternatives like find-my-way or express-path-match.","message":"Library has not been updated in years; no TypeScript definitions or modern ESM support beyond basic CommonJS.","severity":"deprecated","affected_versions":">=0.1.3"},{"fix":"Ensure subsequent middleware handles non-matched methods correctly.","message":"If method is '*', it matches all HTTP methods (GET, POST, etc.) but does not distinguish. In Express, middleware order and next() semantics apply.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use default import: import matchRequest from 'express-match-request'","cause":"Using named import instead of default import in ESM (e.g., import { matchRequest } from 'express-match-request')","error":"TypeError: matchRequest is not a function"},{"fix":"Run: npm install express-match-request","cause":"Package not installed or incorrectly installed","error":"Cannot find module 'express-match-request'"},{"fix":"Ensure you pass method and pattern: app.use(matchRequest('GET', '/path'), handler)","cause":"matchRequest returns a function that must be used as middleware; if called without arguments it returns undefined","error":"matchRequest(...) is not a valid middleware"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}