Registry / database / chaos-json-api

chaos-json-api

JSON →
library7.0.3jsnpmunverified

JSON API adapter for Chaos ORM, enabling RESTful API integration following the JSON:API specification. Current stable version is 7.0.3. This package requires Chaos ORM and an XMLHttpRequest polyfill for Node.js. It serializes and deserializes JSON:API payloads for Chaos entities. Released under the MIT license. Differentiators: seamless integration with Chaos ORM, no additional schema configuration needed.

npm install chaos-json-api
INSTALL
IMPORT
SIG · CHAOS-JSON-API
C
chaos-json-api
databasejavascriptv7.0.3
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.

JAA
import JAA from 'chaos-json-api'
const JAA = require('chaos-json-api').default
Package has a default export. CommonJS require with .default is wrong; use require('chaos-json-api') directly.
JAA
const JAA = require('chaos-json-api')
const { JAA } = require('chaos-json-api')
Not a named export; the entire module is the adapter.
JAA
import JAA from 'chaos-json-api'
import { JAA } from 'chaos-json-api'
Named import results in undefined; use default import.

Shows how to set up Chaos JSON API with a remote JSON:API endpoint, define a model, and fetch a resource.

const JAA = require('chaos-json-api'); const Chaos = require('chaos-orm'); // Configure Chaos connection const connection = Chaos.createConnection({ adapter: 'http', host: 'https://api.example.com', version: '1.0', }); // Create a JSON API source const source = new JAA.Source({ connection }); // Define a model const Post = Chaos.define('posts', { title: String, body: String, }); source.model(Post); // Use the source async function getPost(id) { const post = await source.find('posts', id); console.log(post.title); } getPost(1);
Debug
Known issues
gotchaRequires XMLHttpRequest polyfill in Node.js.
fix
Install and import 'xhr2' or 'xmlhttprequest' before using chaos-json-api in Node.
affects: >=0.0.0
deprecatedThe 'source' property may be deprecated; prefer using the adapter directly.
fix
Check documentation for recommended usage patterns.
affects: >=7.0.0
gotchaModel definitions must be registered with source before performing operations.
fix
Always call source.model(MyModel) after defining the model.
affects: >=7.0.0
Errors
Common errors & fixes
Error: No adapter found for 'http'
Missing or incorrect adapter name in connection configuration.
fix
Use adapter: 'http' and ensure chaos-json-api is installed.
TypeError: JAA is not a constructor
Incorrect import style: using named import instead of default import.
fix
Use const JAA = require('chaos-json-api') or import JAA from 'chaos-json-api'.
Upgrade
Version history
7.0.3latest on npm
Audit
Dependencies
chaos-ormrequiredPeer dependency: core ORM library required for entity management.
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
chaos-json-api — npm install chaos-json-api · libregistry