json-api-query
Validates the parsed query accumulator against a
JSON:API query schema, covering filter, sort,
fields, include, and page parameters. Uses AJV 8 with JSON Schema
2020-12. Must run after url().
Pipeline stage: Validation (after url())
Import
Section titled “Import”import { jsonApiQuery } from "@centralping/ergo";Options
Section titled “Options”| Option | Type | Default | Description |
|---|---|---|---|
...options | * | — | Forwarded to the JSON:API validator |
Return Value
Section titled “Return Value”Returns undefined on success — validation is a gate, not a data
producer.
Error Responses
Section titled “Error Responses”| Status | Condition |
|---|---|
| 400 Bad Request | Query parameters fail JSON:API schema validation |
import { compose, url, jsonApiQuery } from "@centralping/ergo";
const pipeline = compose( {fn: url(), setPath: "url"}, jsonApiQuery(), // acc.url.query is validated against JSON:API conventions);router.get("/articles", { jsonApiQuery: {}, execute: (req, res, acc) => ({ response: { body: queryArticles(acc.url.query), }, }),});RFC References
Section titled “RFC References”API Reference
Section titled “API Reference”See the auto-generated jsonApiQuery API docs.