A complete REST API in under 50 lines
No hand-written handlers, no manual route registration, no boilerplate database code. Just add a data model and a route class, then let RapidREST do the rest!
RapidREST even generates a complete OpenAPI spec.
- DATA MODEL
- REST API
- JOB
- REACT PAGE
import {
DatabaseDecorators, BaseMongoEntity
} from '@rapidrest/service-core';
const { Column, DataStore, Entity } = DatabaseDecorators;
@DataStore('mongo')
@Entity()
export class Pet extends BaseMongoEntity {
@Column()
public name: string = "";
@Column()
public species: string = "";
constructor(other?: any) {
super(other);
if (other) {
this.name = "name" in other ? other.name.trim() : this.name;
this.species = "species" in other ? other.species : this.species;
}
}
}
import {
CRUDRoute, RouteDecorators
} from '@rapidrest/service-core';
import { Pet } from "../models/Pet.js";
const { Model, Route } = RouteDecorators;
@Model(Pet)
@Route('/pets')
export class PetRoute extends CRUDRoute<Pet> {}
import { BackgroundService } from "@rapidrest/service-core";
export class Job extends BackgroundService {
public get schedule(): string | undefined {
return "* * * *"; // Run every minute
}
public async run(): Promise<void> {
// TODO
}
public async start(): Promise<void> {
// TODO
}
public async stop(): Promise<void> {
// TODO
}
}
// src/service/PetService.ts
import { ReactService } from "@rapidrest/react";
@ReactService("/app/pets")
export class PetService {
@Inject(RepoUtils, { name: Pet.name, args: [Pet] })
private petUtils?: RepoUtils<Pet>;
public async function fetchProps() {
return { pets: await this.petUtils?.find() };
}
}
// apps/www/pets.tsx
import "../src/models/Pet.js";
export default function PetsPage({pets}: {pets: Pet[]}) {
return (
<ul>
{pets.map((pet) => (
<li key={pet.id}>{pet.name}</li>
))}
</ul>
);
}
Built for speed
Runs on the high-performance native HTTP library uWebSockets.js so the framework stays out of the way under load.
Decorator-driven, zero boilerplate
Automatically inject dependencies and wire API endpoints with decorators in code — no central app/router or registration files to maintain.
Database Support
Whether you prefer MongoDB or SQL, the built-in ORM layer and CRUD endpoints eliminates the boilerplate needed to build data-driven APIs and apps.
Auth & RBAC
Security first principles with auth and a powerful RBAC/ACL system for per-URL/class/document access control built-in — no separate library to bolt on.
OpenAPI Docs
Automatically generates OpenAPI documentation from your code and serves the spec via common endpoints `/openapi.json`, `/openapi.yaml`
Cache System
The Redis based built-in caching system provides automatic caching of queries, documents, and server rendered React pages. Simply add `@Cache` to your model and you're done!
RapidREST is incredibly fast
RapidREST delivers best-in-class performance out of the box for common workloads compared to other popular frameworks.
Requests per second on single record database read test `get_pet`.
Full methodology & more endpoints →
Battle Tested + Batteries Included
Originally developed to serve as the foundation for the award-winning Game Backend as a Service platform AcceleratXR, RapidREST is a battle-tested framework that has been used in real production at scale. The framework is meticulously designed to offer everything needed to deliver high-quality production-grade RESTful services and apps in minutes.
- HTTP Engine → built on uWebSockets.js for raw speed
- RBAC & ACLs → URL, class-based and document-level protection
- Database Integration → built-in Mongo & ORM (SQL) layer
- Data Caching → cache queries, documents, pages, and more
- OpenAPI → automatically generates OpenAPI docs from your code
- Server-rendered React → unify your front-end and back-end code
From nothing to running in three steps
npx @rapidrest/cli generate server my-apiScaffold a project
rapidrest generate route Pet --modelAdd a model + CRUD routes
rapidrest devRun it!