Skip to content

Latest commit

 

History

History

rest-client

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

REST Client Example

What This Teaches

Use this when you want to call db from app or test code instead of typing curl commands. It demonstrates createDbClient(), direct REST calls, and a REST batch request.

Files To Inspect

Run It

From the repository root, use the repo-internal CLI path:

pnpm run db -- sync --cwd ./examples/rest-client
pnpm run db -- serve --cwd ./examples/rest-client

In another terminal:

ASYNC_DB_URL=http://127.0.0.1:7331 node ./examples/rest-client/src/client-demo.js

Expected Result

sync writes generated schema, types, and runtime state under examples/rest-client/.db/. The demo script prints users from /db/users.json, settings from /db/settings.json, and a two-item batch result.

REST Request To Try

Leave serve running and run this from another terminal:

curl 'http://127.0.0.1:7331/db/users.json?select=id,name,email'

Features To Notice

Cleanup

Generated .db/ output is ignored by git and can be removed whenever you want a fresh mirror.

More Docs