vovk dev
$ 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 commandvovk 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
vovk devandnext devrun together with concurrently .vovk devwatches the /src/modules folder (set bymodulesDir) and the segment route files.- When a file changes, a regular expression check tells whether it holds a controller of a known segment.
- 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. - 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./clientwithout asrc/appfolder). With the segmented client, the per-segment folders go to the same folder.
- If controllers were added, removed or renamed, or methods changed (validation included), the watcher writes the schema to the .vovk-schema folder as
vovk dev runs next to the Next.js dev server. There are two ways to run both, each with concurrently :
- Explicit way: you see the whole command, but you set
PORTyourself:
PORT=3000 npx concurrently 'vovk dev' 'next dev' --kill-othersPass Next.js flags as usual:
PORT=3000 npx concurrently 'vovk dev --https' 'next dev --experimental-https --turbo' --kill-others- 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-devPass next dev flags after --:
npx vovk dev --https --next-dev -- --experimental-https --turboA 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 --exitThe 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"
}
}