Skip to main content

Add-ons

Docker, Kubernetes, a default route, an SSR React app, none of these are things every project needs from day one, so generate server treats them as optional rather than baking them into every scaffold. These six commands add one after the fact, to a project that either skipped it originally or has grown into needing it since. Each is safe to run again later: generate docker/generate k8s/generate default-route regenerate their output from your project's current state (--force to actually overwrite), so re-running one after adding a datastore or route picks up the change rather than leaving stale output behind.

rapidrest generate docker

Adds a Dockerfile and docker-compose.yml, configured for whichever datastores your project already has set up. See Deployment → Docker for what the generated files actually contain.

rapidrest generate docker
docker compose up
FlagDescription
--output-dir <path>Project directory to add to. Defaults to the current directory
-f, --forceOverwrite existing files

Safe to re-run with --force whenever your project's datastores change. It regenerates the output from the current project state rather than patching the existing files.

rapidrest generate k8s

Adds a Helm chart under helm/, for deploying to a real cluster instead of a single container. See Deployment → Kubernetes (Helm) for the chart's structure and every configurable value.

rapidrest generate k8s
FlagDescription
--output-dir <path>Project directory to add to. Defaults to the current directory
-f, --forceOverwrite existing files
--no-installSkip the automatic package manager install that runs afterward, if generating added a new dependency

Same idempotent-regeneration behavior as generate docker.

rapidrest generate default-route

generate server only includes a default route (BaseAdminRoute, BaseMetricsRoute, BaseOpenAPIRoute, BaseStatusRoute, BasePushRoute, BaseACLRoute, BaseStaticRoute) if you asked for it up front. This command adds one, or several, to a project that didn't, without regenerating anything else.

rapidrest generate default-route
rapidrest generate default-route --type admin --type metrics
rapidrest generate default-route --type static --static-path public --api-route
rapidrest generate default-route --type admin --api 2
FlagDescription
-f, --forceOverwrite existing files
--api-route / --no-api-routeUse @ApiRoute instead of @Route for the generated route(s), with no version. Omit both this and --api to be prompted interactively
--api <version>Sets the API version to use with --api-route (e.g. --api 2 for /api/v2). Passing --api alone (without --api-route) also implies --api-route. --api always requires a value — a bare --api with nothing after it fails with Flag --api expects a value; use --api-route by itself for an unversioned /api prefix
-a, --author <name>
--output-dir <path>Defaults to ./src/routes
-t, --type <name>One of acl, admin, metrics, openapi, push, static, status. Pass more than once to generate multiple route types
--static-path <path>Only meaningful with --type static. Path containing the static files to serve. Defaults to public

If --type is omitted, you're prompted interactively to check off which routes to generate (Admin, Metrics, OpenAPI, and Status are checked by default; ACL and Static aren't).

rapidrest generate react NAME

Adds SSR React support to an existing project: the app/ directory convention, a Vite config, and a ReactRoute subclass mounting it, the same pieces generate server --react would have added at scaffold time.

rapidrest generate react app
rapidrest generate react app --path /dashboard --hydrate
FlagDescription
--output-dir <path>Project directory to add to. Defaults to the current directory
-a, --author <name>
-p, --path <base-path>Base path the app routes to. Defaults to /<NAME>
--hydrateEnables client-side hydration
-f, --forceOverwrite existing files
--no-installSkip the automatic package manager install that runs afterward

Adding a second app

Run this command again with a different NAME and it adds another app alongside the first, rather than overwriting it. vite.config.ts is regenerated every time to include every app the project now has (see Hydration → Multiple Apps), so it never needs hand-editing as apps are added. If the project's first app still uses the older single-app layout (a plain app/ directory rather than apps/<name>/), adding a second app migrates it to apps/<name>/ automatically and updates its route class's appDir to match, no manual restructuring required.

rapidrest generate react-page APP NAME

Adds a page to an existing React app, one .tsx file plus, optionally, a server-side data-fetching service, following the App Directory Convention so the new page is routable immediately with no manual wiring.

rapidrest generate react-page app Dashboard
rapidrest generate react-page app Dashboard --service

# NAME can include a subpath
rapidrest generate react-page app my/path/page --service
FlagDescription
--output-dir <path>Project directory to add to. Defaults to the current directory
-a, --author <name>
-s, --serviceAlso generate a companion service class for server-side data fetching (see Data Fetching)
-f, --forceOverwrite existing files

NAME may include a subpath (e.g. my/path/page). Each segment is PascalCased to derive the generated component/service name (my/path/pageMyPathPage).

rapidrest react export

Crawls a project's React app and writes a static HTML/CSS/JS site to disk, no server required to serve the result. Requires a React app to already be configured (see generate react above).

cd my-api
rapidrest react export
rapidrest react export --docker # assume databases are already running
rapidrest react export --port 4000 # prefer port 4000 for the transient export server
FlagDescription
-d, --dockerRun in Docker mode (skips starting in-memory database servers)
-p, --port <n>Preferred port to bind the transient export server to. Defaults to 3000. If already in use, the next available port is used instead

Run this from the root of a generated project with React support. It starts an in-memory instance of each configured datastore (unless --docker is passed), finds a free port for a transient export server, then delegates to @rapidrest/react's own CLI (rapidreact export) to build the client bundle and crawl the app under NODE_ENV=production. The result is written to dist/export/, deploy that directory to any static host. See SSR React → Static Export for the full write-up, including known limitations (no dynamic routes, hydration only from /, props frozen at export time).