Skip to main content

Generate Commands

These four commands cover the everyday shape of building a RapidREST project: one to create it, and three to add the pieces every service eventually needs, a model, a route, a scheduled job. Each one writes a real, editable source file from a template, not a black box you have to work around, so treat the output as a starting point you're expected to modify, not generated code to leave alone.

rapidrest generate server NAME

Scaffolds a brand-new project: src/config.ts, a Server entry point, whichever datastores and default routes you choose, and a test harness already configured to exercise them, all in one runnable directory.

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
--answers <path>Path to a JSON file supplying any of the flags below, for reuse across projects (schema below). Flags always take precedence over the file; either takes precedence over the interactive prompts
--description <text>Short description of the project
-a, --author <name>Falls back to your Git config, then prompts
--pkg-manager <name>One of npm, yarn
--db <name>A database feature to enable. One of mongodb, postgresql, redis, sqlite. Repeatable
--route <name>A default route to include. One of acl, admin, metrics, openapi, push, status (see Default Routes). Repeatable
--react / --no-reactInclude React frontend support
--docker / --no-dockerInclude Docker support
--k8s / --no-k8sInclude Kubernetes (Helm) support
--api-route / --no-api-routePrefix all non-React routes with /api
--api-version <value>API version segment when --api-route is set (e.g. 1 for /api/v1)
--scm <name>Source control manager. One of github, gitlab, git, p4, svn, none
--no-installSkip running the package manager install after generating

Run it bare and you're walked through every choice above as an interactive prompt, the same experience as npm create vite@latest or similar scaffolding tools if you've used one before. Pass any of the flags to skip that specific prompt; pass all of them (or an --answers file) and the command runs start to finish with no prompts at all, useful in a script or CI job that needs to spin up a throwaway project unattended.

--route/--react/--docker/--k8s all stand in for one interactive "additional features" checkbox, so they're treated as a group: passing any one of them (or its --answers equivalent) skips that checkbox entirely, and whichever of the four you didn't specify falls back to that checkbox's own default (--route → none, --react → off, --dockeron, --k8s → off) rather than prompting for just the rest.

Any default routes you selected are generated via generate default-route immediately afterward, using the same author and API prefix chosen here, so generate server --route admin and generate server followed by a separate generate default-route --type admin produce the identical result.

--answers <file> takes a JSON file with any of the flags above as camelCase keys, every key optional:

{
"description": "A product catalog service",
"author": "Jane Doe <jane@example.com>",
"pkgManager": "npm",
"db": ["mongodb", "redis"],
"route": ["admin", "status"],
"react": false,
"docker": true,
"k8s": false,
"apiRoute": true,
"apiVersion": "1",
"scm": "github"
}
# Fully non-interactive, via flags
rapidrest generate server my-api --description "A product catalog service" --pkg-manager npm \
--db mongodb --db redis --route admin --route status \
--docker --api-route --api-version 1 --scm github

# Fully non-interactive, via a reusable profile
rapidrest generate server my-api --answers ./server-profile.json

rapidrest generate model NAME

Adds a data model class to an existing project, the same @Entity/@Identifier-decorated shape you'd otherwise write by hand (see Entities & Columns), pre-wired to a real datastore from your project's src/config.ts.

rapidrest generate model Product
rapidrest generate model Product --datastore mongo --cache 120 --protect
FlagDescription
-f, --forceOverwrite existing files
-o, --output-dir <path>Defaults to ./src/models
-a, --author <name>
-d, --description <text>
--datastore <name>The configured datastore this model binds to
-c, --cache [ttl]Enables @Cache. Bare --cache defaults to a TTL of 60
-p, --protectEnables RBAC protection on the model. Interactively defaults to on
--property <name:type>Add a typed property to the model, as name:type (e.g. quantity:number). Append ? to the type to make it optional (e.g. bio:string?). Repeatable
--no-installSkip running the package manager install after generating (only runs at all if adding this model created a brand-new datastore that needs a new driver dependency)

Every model already has a name: string field (its @Identifier), --property/the interactive prompt add further data properties alongside it, not instead of it. An optional property (type?) is declared as type | undefined with @Nullable and defaults to undefined; a required property gets a type-appropriate zero value ("", 0, false, [], new Date()), so the generated class always compiles even before you fill in real defaults.

rapidrest generate model Product --datastore mongo --cache --protect \
--property quantity:number --property tags:string[] --property "bio:string?"

If you configure a brand-new datastore while adding a model, and Docker or Helm add-ons already exist in the project, you're prompted to regenerate them so the new datastore shows up there too, otherwise a real datastore your model depends on could silently be missing from the deployment configs.

rapidrest generate route NAME

Adds a route class. The most common case, binding it to a model you already generated, produces a full CRUD endpoint (see Auto CRUD Routes) from a single flag rather than writing the six HTTP methods by hand.

rapidrest generate route ProductRoute
rapidrest generate route ProductRoute --model Product --protect
rapidrest generate route ProductRoute --api 2
FlagDescription
-f, --forceOverwrite existing files
--output-dir <path>Defaults to ./src/routes
-a, --author <name>
-d, --description <text>
--path <route-path>Base path, e.g. /api/v1/products
-m, --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>. Requires a value — a bare --api fails with Flag --api expects a value; to get an unversioned /api prefix, omit the flag and answer the interactive prompts (confirm "Is this an API route?", then leave the version blank)
-p, --protectEnables RBAC protection. Interactively defaults to off (opposite of generate model)

Skip --model (or pass --no-model) and you get a plain route class with none of the CRUD scaffolding, a blank slate for a handler that doesn't map to standard create/read/update/delete over one model.

rapidrest generate job NAME

Adds a background job, a plain class run on a schedule rather than in response to a request.

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

Leave --schedule unset and you get a job with an empty schedule to fill in yourself, still a valid starting point if you'd rather write the cron expression directly in the generated file than get it right on the command line.