The Node.js reference server uses anDocumentation 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.
authConfig object to define authorization rules at any level of your data tree. Rules cascade from the most specific matching node toward the root using a deepest-match-wins strategy: the $auth function closest to the requested path is the one that runs.
authConfig Structure
The authConfig object mirrors the shape of your data store. Attach a $auth function to any node to guard that path and everything beneath it.
$auth function receives three arguments:
The Bearer token extracted from the
Authorization header. An empty string if
no Authorization header was sent.The path segments after the node where this
$auth function is defined.
For example, if $auth is on users and the request is for users.user1.name,
then accessArray is ["user1", "name"].What the client is trying to do. See the Operation types
table below.
true to allow the request or false to deny it (the server responds with 403 Forbidden).
Resolution Algorithm
Walk the authConfig tree
Starting from the root of
authConfig, follow the path segments of the
requested path one by one, descending into child nodes.Collect every $auth function encountered
Each time a node along the way has a
$auth function, record it along with
the remaining path segments at that point.Use the deepest match
The
$auth function that was found furthest down the tree is called. It
receives the path segments that come after its own node as accessArray.users.user1.name:
authConfig.users.user1.$authis found → called withaccessArray = ["name"]✓ (deepest — this one runs)authConfig.users.$auth→ would be called withaccessArray = ["user1", "name"](fallback, skipped)- Root
authConfig.$auth→ would be called with all segments (root fallback, skipped)
authConfig.users.user1.$auth is the deepest match, it is the only function that runs.
Operation Types
Theoperation argument tells your $auth function exactly which client action triggered the check.
| Operation | Triggered by |
|---|---|
get | Single path read — GET ?path= |
get:batch | Path appeared in a batched read — GET ?paths= |
get:command | Freeform query — GET ?path=&command= |
set | $set mutation — POST with no __op in the body |
add | $add mutation — POST with __op: "add" |
remove | $remove mutation — POST with __op: "remove" |
operation.startsWith("get") to match all read operations at once.
Common Patterns
Fully public path
Allow everyone, no token required:Read-only path
Reads are open; all mutations are denied:Admin-only path
Only requests carrying the admin token are accepted, for any operation:Locking Down the Root
Add a$auth function directly on the root of authConfig to set a default rule that applies to any path not covered by a more specific node. Specific child rules always override it.
posts and everything beneath it is public, while every other path in the store requires the admin token.
The root
$auth is checked last — it only runs if no more specific $auth
is found for the requested path. It does not run in addition to a matching
child $auth.The
accessArray parameter lets you build dynamic rules — for example,
allowing users to read only their own data by comparing accessArray[0] to a
user ID decoded from the token.