Getting Started
Quick Start
One command scaffolds a typed, validated MoroJS API. You'll have a running server in under a minute.
What You'll Learn
- Scaffold a MoroJS project with the CLI
- Run the dev server and hit your first endpoints
- Add a typed, validated route
Scaffold Your Project
Run the CLI. You'll be prompted for runtime, validation library, and optional features — press enter to accept defaults for a typed REST API.
Scaffold
bash
What this does: Creates my-api/ with TypeScript, ESM, validation, and a working src/index.ts wired up. The CLI auto-detects your package manager and installs dependencies.
Run It
Start the dev server with hot reload:
Start dev server
bash
You'll see the server come up on port 3000. Hit the welcome and health endpoints already scaffolded for you:
GET http://localhost:3000/— welcome endpointGET http://localhost:3000/health— health check
Add a Typed, Validated Route
Open src/index.ts and add a parameterized GET and a validated POST. Save — the dev server reloads automatically.
src/index.ts
typescript
Result: TypeScript knows the shape of req.body from the Zod schema. Invalid requests are rejected automatically before your handler runs.
Prefer to set up MoroJS by hand instead of using the CLI?