Skip to main content

Generate Commands

rapidrest generate server NAME

Scaffolds a brand-new project.

rapidrest generate server my-api
rapidrest generate server my-api --output-dir ~/projects/my-api
FlagDescription
--output-dir <path>Directory to write into. Defaults to ./<NAME>
--forceOverwrite existing files

Everything else is interactive: project description, author (auto-filled from Git config when available), package manager (yarn/npm), databases (MongoDB and Redis checked by default; PostgreSQL and SQLite also available), additional features (React, Docker, checked by default, Kubernetes/Helm), and source control (GitHub, GitLab, Git, Perforce, Subversion, or none).

rapidrest generate model NAME

Adds a data model class.

rapidrest generate model Product
rapidrest generate model Product --datastore mongo --cache 120 --protect
FlagDescription
--output-dir <path>Defaults to ./src/models
--author <name>
--description <text>
--datastore <name>The configured datastore this model binds to
--cache [ttl]Enables @Cache. Bare --cache defaults to a TTL of 60
-p, --protectEnables RBAC protection on the model. Interactively defaults to on
--forceOverwrite existing files

If you configure a brand-new datastore while adding a model, and Docker or Helm add-ons already exist in the project, you'll be prompted to regenerate them so the new datastore is reflected.

rapidrest generate route NAME

Adds a route class.

rapidrest generate route ProductRoute
rapidrest generate route ProductRoute --model Product --protect
rapidrest generate route ProductRoute --api 2
FlagDescription
--output-dir <path>Defaults to ./src/routes
--author <name>
--description <text>
--path <route-path>Base path, e.g. /api/v1/products
--model <name>Bind to a model, generates a CRUDRoute (see Auto CRUD Routes)
--no-modelSkip all prompts about associating a model
--api [version]Use @ApiRoute instead of @Route (see Routing & Controllers). Pass a version to prefix the path with /api/v<version>; bare --api prefixes with /api only
-p, --protectEnables RBAC protection. Interactively defaults to off (opposite of generate model)
-f, --forceOverwrite existing files

rapidrest generate job NAME

Adds a background job.

rapidrest generate job MetricsCollector
rapidrest generate job MetricsCollector --schedule "*/5 * * * *"
FlagDescription
--output-dir <path>Defaults to ./src/jobs
--author <name>
--description <text>
--schedule <cron>Crontab-style schedule
--forceOverwrite existing files