@rapidrest/cli
v0.11.1
Published
The official CLI tool for RapidREST projects
Readme
rapidrest
The official CLI tool for RapidREST projects.
Overview
rapidrest scaffolds and manages RapidREST server projects. It handles the full project lifecycle:
- Scaffold a new server project with your choice of databases, frontend, and deployment targets
- Generate models, routes, background jobs and add-on support (Docker, Kubernetes, React) inside an existing project
- Develop with hot-reload and automatic in-memory database startup
- Build and start the compiled server in one command
Installation
npm install -g @rapidrest/cli
# or
yarn global add @rapidrest/cliRapidREST requires Node.js LTS (24) or later.
Once installed, the CLI is available as both rapidrest and the shorter alias rr. Every example below works with either name.
Quick Start
# 1. Scaffold a new project (interactive prompts guide you through the options)
rapidrest generate server my-api
# 2. Install dependencies
cd my-api && yarn install
# 3. Create a new route
rapidrest generate route MyRoute
# 4. Start the development server
rapidrest devCommands
rapidrest generate server NAMErapidrest generate model NAMErapidrest generate route NAMErapidrest generate job NAMErapidrest generate dockerrapidrest generate k8srapidrest generate react NAMErapidrest generate react-page APP NAMErapidrest devrapidrest startrapidrest build
rapidrest generate server NAME
Scaffold a new RapidREST server project.
USAGE
$ rapidrest generate server NAME [--output-dir <path>] [--force]
ARGUMENTS
NAME Name of the new project (also used as the output directory name)
FLAGS
--output-dir <path> Directory to write the generated project into. Defaults to ./<NAME>
--force Overwrite existing filesThe command walks through an interactive prompt to configure the generated project:
| Prompt | Description | Options |
|--------|---------|
| Project description | Textual description of your project | Free input |
| Author | The author of the project | Auto-filled from your Git config when available; otherwise you're prompted |
| Package manager | The desired Node.js package manager | yarn | npm |
| Databases | Desired database(s) to use in the project | MongoDB , PostgreSQL, Redis , SQLite |
| Additional features | Additional RapidREST features to enable | React, Docker, Kubernetes (Helm) (multi-select) |
| Source control | The SCM to use for the project | GitHub, GitLab, Git, Perforce (Helix), Subversion, or none |
Example:
rapidrest generate server my-api
# → prompts for all options, then writes my-api/ with the selected features
rapidrest generate server my-api --output-dir ~/projects/my-apirapidrest generate model NAME
Generate a new data model class inside the current project.
USAGE
$ rapidrest generate model NAME [--output-dir <path>] [--author <name>] [--description <text>]
[--datastore <name>] [--cache [ttl]] [--protect] [--force]
ARGUMENTS
NAME Name of the data model class (e.g. Product, UserProfile)
FLAGS
-o, --output-dir <path> Directory to write the generated model into. Defaults to ./src/models
-a, --author <name> Author to attribute the generated code to
-d, --description <text> Short description of the model
-ds, --datastore <name> Name of the datastore the model will be bound to
-c, --cache [ttl] Cache TTL (in seconds) for this model
-p, --protect Enable RBAC-based protection for this model
-f, --force Overwrite existing filesIf the project does not contain an existing datastore, or you simply want to want to set up a different datastore than previously configured, this command will help you create a new one.
--cache has three forms:
- Omitted entirely — you're prompted interactively for a TTL (blank disables caching)
- Passed with no value (
--cache) — caching is enabled with the default TTL of60seconds - Passed with a value (
--cache 120) — caching is enabled with that TTL in seconds
Example:
rapidrest generate model Product
# → creates src/models/Product.ts
rapidrest generate model Product --datastore mongo --cache 120 --protectrapidrest generate route NAME
Generate a new route handler inside the current project.
USAGE
$ rapidrest generate route NAME [--output-dir <path>] [--author <name>] [--description <text>]
[--path <route-path>] [--model <name>] [--no-model] [--protect] [--no-test] [--force]
ARGUMENTS
NAME Name of the route class (e.g. ProductRoute, AuthRoute)
FLAGS
--output-dir <path> Directory to write the generated route into. Defaults to ./src/routes
-a, --author <name> Author to attribute the generated code to
-d, --description <text> Short description of the route
--path <route-path> Base path of the route (e.g. /api/v1/products)
-m, --model <name> Name of the model class this route will serve (extends ModelRoute)
--no-model Skip all prompts about associating a model class
-p, --protect Enable RBAC-based protection for this route
--no-test Skip generating the matching test file
-f, --force Overwrite existing filesWhen selecting or creating a data model for the route handler, the resulting class will extend the ModelRoute base class and automatically include the following default endpoints:
HEAD /<path>- Count all documents matching a given query of the specified in the datastoreGET /<path>- Find all documents matching a given query of the specified in the datastorePOST /<path>- Create one or more documents of the specified in the datastoreDELETE /<path>- Deletes all documents matching a given query of the specified in the datastoreGET /<path>/:id- Retrieve a single document for the givenidPUT /<path>/:id- Updates a single document for the givenidPUT /<path>/:id/:property- Updates a single property of the document with the givenidDELETE /<path>/:id- Deletes a single document for the givenid
Example:
rapidrest generate route ProductRoute
# → creates src/routes/ProductRoute.ts and test/ProductRoute.test.ts
rapidrest generate route ProductRoute --model Product --cache --protectrapidrest generate job NAME
Generate a new background job inside the current project.
USAGE
$ rapidrest generate job NAME [--output-dir <path>] [--author <name>] [--description <text>]
[--schedule <cron>] [--force]
ARGUMENTS
NAME Name of the background job class (e.g. MetricsCollector, Notificatier)
FLAGS
-o, --output-dir <path> Directory to write the generated job into. Defaults to ./src/jobs
-a, --author <name> Author to attribute the generated code to
-d, --description <text> Short description of the job
-s, --schedule <cron> Crontab-style schedule the job runs on (e.g. `* * * * *` runs every minute)
-f, --force Overwrite existing filesExample:
rapidrest generate job MetricsCollector
# → creates src/jobs/MetricsCollector.ts and test/jobs/MetricsCollector.test.ts
rapidrest generate job MetricsCollector --schedule "*/5 * * * *" --description "Collects system metrics"rapidrest generate docker
Add Docker support to the current project.
USAGE
$ rapidrest generate docker [--output-dir <path>] [--force]
FLAGS
--output-dir <path> Project directory to add Docker support to. Defaults to the current working directory
-f, --force Overwrite existing filesGenerates a set of Docker and Docker Compose files with pre-configured databases based on the existing project configuration.
Example:
cd my-api
rapidrest generate docker
docker-compose uprapidrest generate k8s
Add Kubernetes (Helm) support to the current project.
USAGE
$ rapidrest generate k8s [--output-dir <path>] [--force]
FLAGS
--output-dir <path> Project directory to add Kubernetes (Helm) support to. Defaults to the current working directory
-f, --force Overwrite existing filesGenerates a Helm chart under helm/, tailored to the project's configured datastores.
Example:
cd my-api
rapidrest generate k8srapidrest generate react NAME
Add a RapidREST-managed React frontend application to the current project.
USAGE
$ rapidrest generate react NAME [--output-dir <path>] [--author <name>] [--path <base-path>]
[--hydrate] [--force]
ARGUMENTS
NAME Name of the React app (e.g. app)
FLAGS
--output-dir <path> Project directory to add React support to. Defaults to the current working directory
-a, --author <name> Author to attribute the generated code to
-p, --path <path> Base path the React application will route to. Defaults to /<NAME>
--hydrate Enable client-side hydration (required for interactive apps)
-f, --force Overwrite existing filesExample:
cd my-api
rapidrest generate react app
rapidrest generate react app --path /dashboard --hydrate
rapidrest devrapidrest generate react-page APP NAME
Add a new page to an existing React app in the current project.
USAGE
$ rapidrest generate react-page APP NAME [--output-dir <path>] [--author <name>] [--service] [--force]
ARGUMENTS
APP Name of the React app to add the page to (e.g. app)
NAME Name of the page, optionally with a subpath (e.g. Dashboard, my/path/page)
FLAGS
--output-dir <path> Project directory to add the page to. Defaults to the current working directory
-a, --author <name> Author to attribute the generated code to
-s, --service Create a service class for server-side data retrieval for the page
-f, --force Overwrite existing filesUnless --service is passed, you're asked whether to generate a companion service class. If you decline, the page component instead exports a client-side fetchProps helper for retrieving its own data.
NAME may include a subpath (e.g. my/path/page), which nests the page component accordingly. The component and service class names are always derived by PascalCasing NAME — each /-, -, or _-separated segment is capitalized and joined, so my/path/page becomes MyPathPage.
Writes apps/<APP>/<NAME>/index.tsx. When a service class is created, it's written flat to src/services/<PascalCase NAME>Service.ts regardless of NAME's subpath.
Example:
cd my-api
rapidrest generate react-page app Dashboard
rapidrest generate react-page app Dashboard --service
# Nested page path — creates apps/app/my/path/page/index.tsx and src/services/MyPathPageService.ts
rapidrest generate react-page app my/path/page --servicerapidrest dev
Start the RapidREST server in development mode with hot reloading.
USAGE
$ rapidrest dev [--inspect] [--docker]
FLAGS
--inspect Enable the Node.js inspector on port 9229 for debugger attachment
-d, --docker Run in Docker mode (skips starting in-memory database servers)Run this command from the root of a generated RapidREST project. It:
- Reads
src/config.tsto detect which databases are configured. - Starts an in-process, in-memory server for each configured database (MongoDB, PostgreSQL, and/or Redis) — no local database installation required. Pass
--dockerto skip this step when your databases are already running elsewhere (e.g. viadocker compose). - Starts the server via
tsx --watch, watchingsrc/for changes. - If the project has React support configured (a
vite.config.tsis present), also startsvite build --watchconcurrently.
All child processes and started databases are cleaned up on CTRL+C.
Example:
cd my-api
rapidrest dev
rapidrest dev --inspect # attach a debugger on localhost:9229
rapidrest dev --docker # assume databases are already running (e.g. via Docker Compose)rapidrest start
Build and start the RapidREST server for production.
USAGE
$ rapidrest start [--no-build] [--docker]
FLAGS
--no-build Skip the build step
-d, --docker Run in Docker mode (skips starting in-memory database servers)Run this command from the root of a generated RapidREST project. It:
- Runs
yarn buildornpm run build(auto-detected fromyarn.lock/package.json). - If the project has React support configured, also runs
vite buildto compile the frontend. - Reads
src/config.tsto detect which databases are configured and starts an in-memory server for each one — unless--dockeris passed, in which case this step is skipped. - Starts the compiled server (
node dist/server.js, or the equivalent path for your build output).
Example:
cd my-api
rapidrest start
rapidrest start --no-build # skip build, just start databases + server
rapidrest start --docker # assume databases are already runningrapidrest build
Build the RapidREST server project in the current directory.
USAGE
$ rapidrest buildRuns the project's build script via the detected package manager. Equivalent to yarn build or npm run build from the project root.
Regenerating add-ons after project changes
generate docker and generate k8s are idempotent and safe to re-run with --force whenever the project's datastores change — they regenerate their output entirely from the current project state rather than patching existing files. generate model will offer to do this for you automatically when you configure a brand-new datastore while adding a model.
