Getting Started
This walks through installing the CLI, scaffolding a project, and running it locally. No database installation required.
RapidREST requires Node.js 24 or later.
Install the CLI
npm install -g @rapidrest/cli
This installs the rapidrest command (also available as the shorter rr alias, both invoke the exact same binary, use whichever you prefer).
Scaffold a project
rapidrest generate server my-api
This walks you through an interactive prompt:
| Prompt | What it controls |
|---|---|
| Project description | Free-text description written into package.json |
| Author | Auto-filled from your Git config when available |
| Package manager | yarn or npm |
| Databases | MongoDB and Redis are checked by default; PostgreSQL and SQLite are also available. Redis is recommended since it backs the @Cache decorator |
| Additional features | React (server-rendered pages), Docker (checked by default), Kubernetes (Helm) |
| Source control | GitHub, GitLab, Git, Perforce, Subversion, or none |
You can also skip straight to a non-interactive run for the parts you already know:
rapidrest generate server my-api --output-dir ~/projects/my-api
Install dependencies
cd my-api
yarn install
Run it
rapidrest dev
rapidrest dev reads src/config.ts to see which datastores your project is configured for, then automatically starts an in-memory instance of each one (MongoDB, PostgreSQL, and/or Redis). There's nothing to install or run separately for local development. It then starts your server via tsx --watch, restarting on every source change. If you selected the React feature, it also runs vite build --watch alongside it. Everything is cleaned up when you hit Ctrl+C.
By default the server listens on port 3000. Confirm it's up:
curl http://localhost:3000/status
That works because the scaffold already includes a ready-made StatusRoute.ts, along with equivalents for /admin, /metrics, /openapi, and
/push (and /acls, if you kept a database selected). These are thin subclasses of the framework's Default Routes that you're
free to edit, lock down, or delete.
Project layout
A freshly generated project looks roughly like this:
my-api/
├── src/
│ ├── config.ts # nconf-based configuration (see Core Concepts)
│ ├── server.ts # server entry point
│ ├── models/ # entity classes (@Entity, @DataStore, ...)
│ ├── routes/ # route classes (@Route, @Get, ...)
│ └── jobs/ # background jobs, if generated
├── apps/
│ └── app/ # SSR React pages, only if the React feature was selected
├── test/
├── docker-compose.yml # only if the Docker feature was selected
├── helm/ # only if the Kubernetes feature was selected
├── tsconfig.json # extends @rapidrest/service-core/tsconfig
└── package.json
Every class you export anywhere under src/ is automatically discovered and wired up. There's no central file where routes or models get registered. See Core Concepts for how that works.
RapidREST's decorators require experimentalDecorators and emitDecoratorMetadata. Rather than setting these by hand, extend the framework's base config:
{
"extends": "@rapidrest/service-core/tsconfig",
"compilerOptions": {"rootDir": ".", "outDir": "dist"},
"include": ["src"]
}
Add a model and CRUD routes
rapidrest generate model Pet --datastore mongo
rapidrest generate route PetRoute --model Pet
This gives you a full set of CRUD endpoints for Pet. See Auto CRUD Routes for exactly what gets generated.
Next steps
- Core Concepts: dependency injection, auto-discovery, and configuration
- Routing & Controllers: writing your own endpoints
- Default Routes: what the generated
AdminRoute,MetricsRoute,OpenAPIRoute,StatusRouteandPushRoutefiles actually do - SSR React: server-rendered pages in the same project
- CLI Reference: every
generatecommand in detail