Project Generator

Templates, modules, deploy targets and flags of create-vercube, vercube init and vercube add

create-vercube is vercube init: it downloads a template, pins every @vercube/* package to its own version, applies a recipe per module and per deploy target, installs the dependencies and initializes git. A project created today keeps building when the next release ships.

$ pnpm create vercube my-app \
    --template fullstack-vue \
    --modules schema,auth,testing \
    --yes

Templates

TemplateWhat you get
apiA Vercube API: src/index.ts, src/boot/Container.ts, one controller, oxlint and oxfmt. The default
fullstack-vueA workspace: apps/api (the API) and apps/web (Vue on Vite), with packages/ for shared code. One dev at the root starts both, Vite proxies /api to the API, and the web app calls it through @vercube/client, typed by the API's controllers

In the fullstack template the modules are added to apps/api. A React template is planned; Deno supports the api template only.

Modules

ModuleFlag valueWhat the recipe adds
Schema / OpenAPIschemaSchemaPlugin, a validated route documented at /_schema/docs
AuthauthAn API key provider (API_KEY, generated into .env), a route behind @Auth()
StoragestorageStorageManager with a memory or S3 mount, a read/write route
CachecacheCacheManager on a storage mount (adds Storage), a @Cache() route
QueuequeueQueuePlugin with the chosen driver, a consumer and a route that publishes to it
SchedulerschedulerSchedulerPlugin with the chosen store, an interval job (and a cron job with a shared store)
WebSocketswsWebsocketPlugin, a gateway at /chat
TelemetrytelemetryTelemetryPlugin, OpenTelemetry started before the app, the OTLP exporter
DevtoolsdevtoolsDevtoolsPlugin at /_devtools, with a token for production
Testingtestingvitest, @vercube/testing, a test for the starter controller

Schema, Testing and Devtools are selected by default. A module another one needs is added with it and named in the summary: Cache adds Storage.

Modules with a choice ask for it, or take a flag:

FlagValuesDefault
--queuebullmq, rabbitmq, kafka, memorybullmq
--scheduler-storememory, redis, postgresmemory
--storagememory, s3memory

S3 is the exception: no local service is added, set the bucket, region and credentials (and an endpoint for an S3-compatible service such as MinIO) in .env. Any other driver with a server behind it adds the server to docker-compose.yml, published on 127.0.0.1 only, and its URL to .env and .env.example. Redis is added once when both the queue and the scheduler use it. The queue and the scheduler also turn on shutdown.handleSignals: an open broker or store connection would otherwise keep the process running after SIGTERM or Ctrl-C.

With vercube init, a flag for a module that is not selected, such as --queue with --modules none, fails rather than being ignored, and so does a mistyped flag.

Deploy targets

Flag valueWhat changes
nodeNothing: vercube build, then node dist/index.mjs (or Bun, or Deno). The default
aws-lambdaexport const handler in src/index.ts, serverless.yml, offline and deploy scripts
azure-functionssrc/functions/httpTrigger.ts, host.json, local.settings.json (gitignored), a second build entry

app.listen() stays in the entry for both serverless targets: vercube dev needs it, and it binds no port on Lambda or Azure.

Flags

Flag
<dir>Where to create the project
--templateapi or fullstack-vue
--modulesComma separated, or none
--deploynode, aws-lambda or azure-functions
--package-managerpnpm, npm, yarn, bun or deno; the one running the CLI by default
--yesTake the default for every question no flag answers; a non-empty directory still needs --force
--forceReplace the contents of a directory that is not empty (its .git stays)
--no-installSkip installing dependencies
--no-git-initSkip git init

Without a terminal (CI, an agent) and without --yes, a missing answer fails with every flag still needed, instead of waiting for input:

ERROR  Missing --template, --queue, --deploy, --package-manager.
       Pass them, or --yes for the defaults, when there is no terminal to ask in.

Example:
  vercube init my-app --template api --modules schema,testing --deploy node --yes

Adding modules to a project

vercube add applies the same recipes to an existing project. It takes the module question flags (--queue, --scheduler-store, --storage), --yes, --no-install and --cwd:

$ pnpm vercube add queue --queue rabbitmq
$ pnpm vercube add cache,ws --yes

Every recipe checks what is there before it adds anything, so adding a module twice changes nothing, and a file you edited is never overwritten. Code is edited through its syntax tree: a plugin goes into the plugins of vercube.config.ts, a binding into the exported function of src/boot/Container.ts that takes the container. When a recipe cannot find either, it stops and says what to add by hand.

A package can ship a recipe of its own, see Writing a recipe:

$ pnpm add @acme/vercube-search
$ pnpm vercube add @acme/vercube-search

In a fullstack project, install the package with pnpm --filter api add.