Skip to Content
vovk dev

vovk dev

Quick CLI Ref
$ npx vovk dev --help Usage: vovk dev|d [options] [nextArgs...] Start schema watcher (optional flag --next-dev to start it with Next.js) Arguments: nextArgs extra arguments for the implicit next dev command call Options: --next-dev start schema watcher and Next.js with automatic port allocation --exit kill the processes when schema and client are generated --schema-out <path> path to schema output directory (default: .vovk-schema) --https, --dev-https use HTTPS for the dev server (default: false) --log-level <level> set the log level -h, --help display help for command

vovk dev runs a watcher that keeps the schema and the client up to date. It reads the schema of a segment with an HTTP GET request to /api/<segment-name>/_schema_.

How It Works

  1. vovk dev and next dev run together with concurrently .
  2. vovk dev watches the /src/modules folder (set by modulesDir) and the segment route files.
  3. When a file changes, a regular expression check tells whether it holds a controller of a known segment.
  4. The watcher requests /api/<segment-name>/_schema_ of that segment for the new schema. When the file holds no known controller, as with a renamed controller, a service or a validation module, it requests the schema of every segment.
  5. If the schema changed:
    • If controllers were added, removed or renamed, or methods changed (validation included), the watcher writes the schema to the .vovk-schema folder as <segment-name>.json.
    • If the controller list changed, the watcher also generates the client again. The client imports the schema JSON files to set up the library it exports. By default, the composed client goes to ./src/client (or ./client without a src/app folder). With the segmented client, the per-segment folders go to the same folder.
vovk dev

vovk dev runs next to the Next.js dev server. There are two ways to run both, each with concurrently :

  1. Explicit way: you see the whole command, but you set PORT yourself:
PORT=3000 npx concurrently 'vovk dev' 'next dev' --kill-others

Pass Next.js flags as usual:

PORT=3000 npx concurrently 'vovk dev --https' 'next dev --experimental-https --turbo' --kill-others
  1. Implicit way: the port is chosen for you. By default, the command takes port 3000, or the next free port if 3000 is in use:
npx vovk dev --next-dev

Pass next dev flags after --:

npx vovk dev --https --next-dev -- --experimental-https --turbo

A port passed this way (-p 4000 or --port 4000) replaces the automatic one, for Next.js and for the schema requests.

The implicit way uses the concurrently API, so both ways work almost the same.

See HTTPS in development.

Run and Exit

--exit stops the processes that vovk dev started once the schema and the client are generated. Use it for a one-off run, without a watcher.

npx vovk dev --next-dev --exit

The command exits with code 1 when a segment’s schema can’t be fetched after 5 attempts or can’t be used, when the client fails to generate, or when the next dev that --next-dev started stops first.

Add a script for it to package.json:

{ "scripts": { // ... "dev-exit": "vovk dev --next-dev --exit", // or "dev-exit": "cross-env PORT=3000 concurrently \"vovk dev --exit\" \"next dev\" --kill-others" } }
Last updated on