-
Notifications
You must be signed in to change notification settings - Fork 0
Configuration
yrest resolves options from three sources in ascending priority:
schema defaults → yrest.config.yml → CLI flags
Only flags explicitly passed on the command line override the config file. Defaults never shadow values set in the config file.
Run yrest init to generate a yrest.config.yml template, or create it manually:
file: db.yml # YAML database file
port: 3070 # Port to listen on
host: localhost # Host to bind
# base: /api # Base path prefix for all routes
# watch: false # Reload db file on change
# readonly: false # Block write operations (POST, PUT, PATCH, DELETE)
# delay: 0 # Simulated network latency in milliseconds
# pageable: false # Wrap GET collections in { data, pagination }
# snapshot: false # Save initial db state and expose /_snapshot endpointsyrest looks for yrest.config.yml in the current working directory.
If it does not exist, all values fall back to their defaults.
yrest serve [file] [options]| Flag | Short | Default | Description |
|---|---|---|---|
--port <number> |
-p |
3070 |
Port to listen on |
--host <host> |
-H |
localhost |
Host to bind |
--base <path> |
-b |
`` | Base path prefix (e.g. /api) |
--watch |
-w |
false |
Reload db file on change |
--readonly |
-r |
false |
Block all write operations |
--delay <ms> |
-d |
0 |
Simulated latency in ms |
--pageable [limit] |
— | false |
Pageable envelope (default limit: 10) |
--snapshot |
— | false |
Enable snapshot endpoints |
Path to the YAML database file. Relative to the current working directory.
yrest serve db.yml
yrest serve data/mock.ymlDefault: db.yml
Port the HTTP server listens on.
yrest serve --port 8080Default: 3070
Host the server binds to. Use 0.0.0.0 to expose on all network interfaces.
yrest serve --host 0.0.0.0Default: localhost
URL prefix applied to all resource routes. Does not affect meta endpoints
(/_about, /_snapshot).
yrest serve --base /api
# Routes become: /api/users, /api/posts, etc.Default: (empty — routes start at /)
Reloads the YAML file automatically when it changes on disk. Useful during development when you edit the database manually.
yrest serve --watchAdding or removing entire collections requires a server restart. Only changes within existing collections are picked up on reload.
Default: false
Rejects all mutating requests (POST, PUT, PATCH, DELETE) with 405 Method Not Allowed.
GET requests are unaffected.
yrest serve --readonlyDefault: false
Adds a fixed delay (in milliseconds) to every response. Useful for simulating real network latency in frontend development.
yrest serve --delay 300Default: 0
Wraps GET collection responses in a { data, pagination } envelope.
Accepts true (default limit: 10) or a number to set the default page size.
yrest serve --pageable # limit: 10
yrest serve --pageable 25 # limit: 25Config file:
pageable: true # limit: 10
pageable: 25 # limit: 25Default: false
Saves a deep copy of the database state at startup and exposes three endpoints:
-
GET /_snapshot— snapshot metadata and item counts -
POST /_snapshot/save— update the snapshot to the current state -
POST /_snapshot/reset— restore the database to the last snapshot
yrest serve --snapshotDefault: false
yrest init [options]| Flag | Short | Default | Description |
|---|---|---|---|
--file <name> |
-f |
db.yml |
Output filename for the database |
--sample <name> |
-s |
basic |
Sample template to use |
Available samples: basic, relational
yrest init # basic sample → db.yml
yrest init --sample relational # relational sample with _rel
yrest init --file mock.yml # custom filename