Ir al contenido

CLI Reference

Esta página aún no está disponible en tu idioma.

All yRest functionality is accessible through the yrest CLI. Run yrest --help or yrest <command> --help for inline documentation.

Terminal window
yrest <command> [options]

Start the mock server from a YAML file.

Terminal window
yrest serve db.yml [options]
yrest serve db.yml --port 4000 --watch --delay 200
FlagShortTypeDefaultDescription
--port-pnumber3070Port to listen on
--host-hstringlocalhostHost to bind
--base-bstringURL prefix for all routes (e.g. /api/v1)
--watch-wbooleanfalseReload database on file changes
--readonly-rbooleanfalseReject all write operations (POST/PUT/PATCH/DELETE)
--delay-dnumber0Add simulated latency in ms to every response
--snapshot-sbooleanfalseEnable /_snapshot save/reset endpoints
--pageablenumber?Wrap list responses in { data, pagination }
--id-strategyincrement|uuidincrementStrategy for auto-assigning id on POST

Scaffold a new db.yml and optional yrest.config.yml in the current directory.

Terminal window
yrest init
yrest init --sample relational
yrest init --sample ecommerce
FlagTypeDescription
--samplebasic|relational|ecommerceTemplate to use (default: basic)
--configbooleanAlso create yrest.config.yml

Scaffold a handler function stub in yrest.handlers.js.

Terminal window
yrest handler login
yrest handler login --method POST --path /login
yrest handler login --method POST --path /login --register
FlagTypeDescription
--methodstringHTTP method hint (adds JSDoc comment)
--pathstringPath hint (adds JSDoc comment)
--registerbooleanAlso add the _routes entry to db.yml

Generate TypeScript interfaces from the YAML database schema.

Terminal window
yrest types db.yml
yrest types db.yml --output db.types.ts
yrest types db.yml --output db.types.ts --watch