Registry / database / rest-query-shared

rest-query-shared

JSON →
library0.35.1jsnpmunverified

Shared utilities for the restQuery library that enables performing REST queries directly on your database. Version 0.35.1 targets Node.js >=16.13.0 and browsers. Works alongside rest-query-node and rest-query-browser to provide a unified REST-like query interface. The shared package handles query parsing, validation, and type definitions for both environments. No major competitors for this specific approach; key differentiator is direct database queries via REST.

npm install rest-query-shared
INSTALL
IMPORT
SIG · REST-QUERY-SHARED
R
rest-query-shared
databasejavascriptv0.35.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

restQueryShared
import restQueryShared from 'rest-query-shared'
const restQueryShared = require('rest-query-shared')
Package is ESM-only; CommonJS require will not work without dynamic import.
parseQuery
import { parseQuery } from 'rest-query-shared'
import parseQuery from 'rest-query-shared'
parseQuery is a named export, not default.
validateQuery
import { validateQuery } from 'rest-query-shared'
import { validateQuery } from 'rest-query-shared/validation'
Subpath imports are not supported; all exports are at package root.

Parses a REST query string and validates the resulting structure. Demonstrates basic usage of parseQuery and validateQuery.

import { parseQuery, validateQuery } from 'rest-query-shared'; const query = 'users?age>=18&status=active'; const parsed = parseQuery(query); console.log(parsed); // { resource: 'users', filters: [{ field: 'age', op: '>=', value: 18 }, { field: 'status', op: '=', value: 'active' }] } const isValid = validateQuery(parsed); console.log(isValid); // true
Debug
Known issues
breakingparseQuery signature changed: v0.35.0 swapped argument order from (query, options) to (options, query).
fix
Update calls to parseQuery(options, query) instead of parseQuery(query, options).
affects: >=0.35.0
deprecatedvalidateQuery no longer checks database schema; that functionality moved to rest-query-node/server.
fix
Use validateQuery only for structural checks; schema validation must be done server-side.
affects: >=0.30.0
gotchaThis package does not include any database drivers; it only parses/validates queries. You must pair with a database-specific adapter.
fix
Install a rest-query adapter like rest-query-mongodb or rest-query-postgres.
affects: all
gotchaThe package uses ESM only. Node.js <16.13.0 will not work without experimental ESM support flags.
fix
Upgrade Node.js to >=16.13.0 or enable --experimental-modules (not recommended).
affects: >=0.35.0
deprecatedThe 'resource' field in parsed queries is no longer validated to match known resources; that check moved to server-side packages.
fix
Remove any resource validation logic in client code; rely on the backend adapter.
affects: >=0.30.0
breakingRemoved 'type' property from parsed query filters (previously 'type' was 'number' or 'string'). Now values are raw without type hint.
fix
Adjust any code that relied on the 'type' property; use typeof or custom type checking.
affects: >=0.35.0
Errors
Common errors & fixes
SyntaxError: Unexpected token '?'
Attempting to parse a query string that uses a non-standard operator (e.g., '?like' without proper encoding).
fix
Ensure query strings follow the supported operator syntax: '=', '!=', '<', '<=', '>', '>=', 'like', 'in'.
TypeError: restQueryShared is not a function
Default import of the entire module instead of named exports.
fix
Use named imports: import { parseQuery } from 'rest-query-shared'.
ERR_REQUIRE_ESM
Using require() to load an ESM-only package.
fix
Use dynamic import: const restQueryShared = await import('rest-query-shared').
Error: Query validation failed: unknown operator '>='
Using an unsupported operator spelling (e.g., 'gte' instead of '>=').
fix
Check the list of supported operators and use '>=', '<=', etc.
Upgrade
Version history
0.35.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Amazon
1
Resources
rest-query-shared — npm install rest-query-shared · libregistry