Registry / web-framework / express-match-request

express-match-request

JSON →
library0.1.3jsnpmunverified

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.

npm install express-match-request
INSTALL
IMPORT
SIG · EXPRESS-MATCH-REQU
E
express-match-request
web-frameworkjavascriptv0.1.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import matchRequest from 'express-match-request'
const { matchRequest } = require('express-match-request')
Package exports a single function as default export. CommonJS users must use require('express-match-request').default or assign to a default import.
matchRequest
const matchRequest = require('express-match-request')
import { matchRequest } from 'express-match-request'
CommonJS require returns the default export directly as a function.
Pattern
import matchRequest from 'express-match-request'
No named exports; only a default function. No type definitions provided.

Demonstrates using matchRequest as middleware to conditionally handle GET /api/users and serve static files on /public.

import express from 'express'; import matchRequest from 'express-match-request'; const app = express(); // Match requests to GET /api/users app.use(matchRequest('GET', '/api/users'), (req, res) => { res.json({ message: 'Users endpoint' }); }); // Match all methods to /public app.use(matchRequest('*', '/public'), express.static('public')); app.listen(3000, () => console.log('Server running on port 3000'));
Debug
Known issues
gotchaPattern matching is simple equality, not RegExp or path-to-regexp. Complex patterns (e.g., '/users/:id') will not work as expected.
fix
Use a library like express-path-match for parameterized routes.
affects: >=0.0.0
deprecatedLibrary has not been updated in years; no TypeScript definitions or modern ESM support beyond basic CommonJS.
fix
Consider alternatives like find-my-way or express-path-match.
affects: >=0.1.3
gotchaIf method is '*', it matches all HTTP methods (GET, POST, etc.) but does not distinguish. In Express, middleware order and next() semantics apply.
fix
Ensure subsequent middleware handles non-matched methods correctly.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: matchRequest is not a function
Using named import instead of default import in ESM (e.g., import { matchRequest } from 'express-match-request')
fix
Use default import: import matchRequest from 'express-match-request'
Cannot find module 'express-match-request'
Package not installed or incorrectly installed
fix
Run: npm install express-match-request
matchRequest(...) is not a valid middleware
matchRequest returns a function that must be used as middleware; if called without arguments it returns undefined
fix
Ensure you pass method and pattern: app.use(matchRequest('GET', '/path'), handler)
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
expressrequiredpeer dependency; designed as Express middleware
Agent activity
2 hits · last 30 days
node
2
Resources
express-match-request — npm install express-match-request · libregistry