Registry / web-framework / qs-middleware

qs-middleware

JSON →
library1.0.3jsnpmunverified

The `qs-middleware` package provides a Connect-compatible middleware designed for parsing URL querystrings and populating the `request.query` property. It integrates with the widely used `qs` module for robust querystring parsing, allowing users to pass configuration options directly to `qs` (e.g., `allowDots`, `arrayLimit`). Currently at version 1.0.3, the project appears to be unmaintained, with its last significant code activity dating back to 2016. Its primary function is to abstract the direct interaction with `qs` for traditional Connect and Express applications, making it straightforward to access parsed query parameters. Given its age, it primarily supports CommonJS environments and older Node.js versions, lacking native ES Module support.

npm install qs-middleware
INSTALL
IMPORT
SIG · QS-MIDDLEWARE
Q
qs-middleware
web-frameworkjavascriptv1.0.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.

query
const query = require('qs-middleware');
import query from 'qs-middleware';
This package is a CommonJS module and does not natively support ES Modules `import` syntax. Attempting to use `import` will likely lead to runtime errors or require specific Node.js interop configurations (`createRequire`) or bundler setups.
query
const query = require('qs-middleware');
import { query } from 'qs-middleware';
The `qs-middleware` package exports a single function as its module.exports. There are no named exports available for destructuring in CommonJS or ES Modules contexts.

This quickstart demonstrates how to set up `qs-middleware` with a basic Connect server to automatically parse URL querystrings into `request.query`. It shows how to pass options to the underlying `qs` module and confirms how the parsed query is accessible and returned in the HTTP response.

const http = require('http'); const connect = require('connect'); const query = require('qs-middleware'); const app = connect(); // Create a simple Connect application that uses qs-middleware // Pass options directly to the underlying 'qs' module, e.g., allowDots app.use(query({ allowDots: true, depth: 5 })); app.use(function(request, response) { console.log('Parsed Query:', request.query); response.setHeader('Content-Type', 'application/json'); response.end(JSON.stringify({ message: 'Query parsed successfully!', query: request.query, example_urls: [ 'http://localhost:3000/?name=Alice&age=30', 'http://localhost:3000/?user.name=Bob&items[0]=apple&items[1]=orange&foo=bar&nested[a][b][c]=d' ] }, null, 2)); }); const server = http.createServer(app); server.listen(3000, () => { console.log('Connect app with qs-middleware running on http://localhost:3000'); console.log('Try visiting: http://localhost:3000/?name=Alice&age=30'); console.log('Or with qs options in effect: http://localhost:3000/?user.name=Bob&items[0]=apple&items[1]=orange'); });
Debug
Known issues
breakingThis package is a CommonJS module and does not natively support ES Module (ESM) import syntax. Direct `import` statements will fail in pure ESM environments without specific Node.js interop (`createRequire`) or bundler configurations.
fix
Use `const query = require('qs-middleware');` for CommonJS projects or rely on a bundler's CJS-to-ESM transpilation for ESM projects.
affects: >=1.0.0
gotchaThe project is abandoned (last commit 2016), meaning it bundles an older version of the `qs` module. This might lead to unexpected querystring parsing behaviors or a lack of features/fixes present in newer `qs` releases.
fix
Inspect the `package-lock.json` of `qs-middleware` to determine the bundled `qs` version. If modern `qs` features or bug fixes are required, consider a more actively maintained alternative or manually parse `request.url` with a modern `qs` version.
affects: >=1.0.0
gotchaAs an abandoned project, `qs-middleware` will not receive security updates. Any vulnerabilities found in its dependencies (like `qs`) or in the middleware itself will remain unaddressed.
fix
For production applications or those requiring robust security, it is strongly recommended to use a more actively maintained querystring parsing solution or to implement custom parsing using a modern, regularly updated `qs` version directly.
affects: >=1.0.0
gotchaWhile `qs-middleware` works with frameworks like Express (which builds on Connect), Express itself provides robust built-in `req.query` parsing. Using `qs-middleware` with Express might be redundant or potentially cause conflicts if not carefully managed alongside Express's native parsers.
fix
For Express applications, evaluate if `qs-middleware` is truly necessary. Express's default `req.query` parsing is often sufficient, and `express.urlencoded()` can be used for body parsing. Only use `qs-middleware` if its specific `qs` configuration cannot be replicated or overridden via Express's defaults.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , qs_middleware__WEBPACK_IMPORTED_MODULE_0__.default) is not a function
Attempting to import `qs-middleware` using ES Module `import` syntax in an environment that doesn't correctly handle CommonJS interop, or mistakenly assuming a default export.
fix
Change the import statement to `const query = require('qs-middleware');`. If in an ESM file, you might need to use `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const query = require('qs-middleware');` or rely on bundler configuration.
Querystring parsing behavior differs from expected (e.g., dots not treated as nested objects, arrays not parsed correctly)
The `qs-middleware` package bundles an older version of the `qs` library, which might have different default behaviors or lack newer configuration options compared to a separately installed, modern `qs`.
fix
Ensure you are passing the correct `options` object to `query()` (e.g., `{ allowDots: true }`). If the issue persists, the bundled `qs` version might be too old; consider abandoning `qs-middleware` in favor of directly using a modern `qs` library to parse `request.url` manually.
ReferenceError: require is not defined in ES module scope
Trying to use `require()` in an ES Module (`.mjs` file or `type: "module"` in `package.json`) without proper setup.
fix
For CommonJS modules like `qs-middleware` in an ES Module context, you can create a `require` function using `import { createRequire } from 'module'; const require = createRequire(import.meta.url);` at the top of your file, then use `const query = require('qs-middleware');`.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
qsrequiredCore dependency for robust querystring parsing.
Agent activity
7 hits · last 30 days
node
6
Resources
qs-middleware — npm install qs-middleware · libregistry