TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/michael-tiger-2010/dragonjson/llms.txt
Use this file to discover all available pages before exploring further.
server/nodejs/server.js file is a complete, zero-dependency reference implementation of the dragonJSON server protocol. It uses only Node.js built-ins (http and url) — no npm install required. The in-memory store can be swapped for any persistence backend by replacing three functions: getByPath, setByPath, and deleteByPath.
Starting the Server
3000 by default, logs a confirmation message, and enables CORS for all origins so browser clients can connect without a proxy.
Data Store
The in-memorystore object at the top of server.js is the entire database. It is a plain JavaScript object that mirrors the shape of your API:
Reads a value by following the given path segments through
obj. Returns
undefined if any segment along the way is missing or not an object.Writes
value at the location described by segments. Creates intermediate
objects along the path if they do not exist.Deletes the key at the location described by
segments. Returns true if the
key existed, false otherwise.Request Routing
All requests arrive at the same base URL. The server determines what to do from the HTTP method and the query parameters.GET ?paths= — batched read
Parses the paths JSON array, resolves each path against the store, and returns a flat response object. Paths that do not exist — or that fail the authorization check — are set to null rather than being omitted.
GET ?path=&command= — freeform query
Parses the command JSON object and passes it to handleCommand along with the data at path. The result is returned directly — it is not cached by the client.
$get commands for the available actions.
GET ?path=&hierarchical=true&target= — hierarchical batch
Walks the store from the root down to target, populating a __batch envelope with the value at every intermediate path. Used when enableHierarchicalBatch: true is set on the client.
GET ?path= — single-path read
The simplest case. Looks up the value at path in the store and returns it directly, or 404 if nothing exists there.
POST ?path= — mutation
Reads the request body, determines the operation from body.__op, checks authorization, and dispatches to the appropriate handler:
body.__op | Operation | Handler |
|---|---|---|
| (absent) | $set | Writes body to path in the store |
"add" | $add | Appends body.value under path, using body.key if provided |
"remove" | $remove | Deletes the node at path |
{ "invalidate": [...] }. See the protocol spec for the full response contract.
Built-in $get Commands
The handleCommand function in server.js provides two built-in actions. Pass them as the command parameter from the client using .$get().
paginate
Slices an object or array and returns a page of results with cursor-based pagination.
Command shape:
nextCursor is null when there are no more pages.
Example:
search
Performs a case-insensitive full-text filter over the string-serialised values of an object. Returns an array of matching entries, each with a key property prepended.
Command shape:
Unknown commands
If theaction is not recognised, handleCommand returns the data at path unchanged. You can add custom commands before the built-in handlers (see below).
Adding Custom Commands
ThehandleCommand function is where you extend the server with your own $get actions. Add your handlers at the top of the function, before the built-in paginate and search checks:
get:command operation. Configure access in authConfig using the "get:command" operation string — see Server Auth for details.