Skip to main content

Getting Started

This walks through installing the CLI, scaffolding a project, and running it locally. No database installation required.

Requirements

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:

PromptWhat it controls
Project descriptionFree-text description written into package.json
AuthorAuto-filled from your Git config when available
Package manageryarn or npm
DatabasesMongoDB and Redis are checked by default; PostgreSQL and SQLite are also available. Redis is recommended since it backs the @Cache decorator
Additional featuresReact (server-rendered pages), Docker (checked by default), Kubernetes (Helm)
Source controlGitHub, 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.

tsconfig.json

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