Quick Start
Get up and running with MoroJS in minutes. This guide will walk you through creating your first high-performance API.
What You'll Learn
- How to set up your first MoroJS project
- Create your first API endpoint
- Add validation and type safety
- Run and test your API
Prerequisites
- Node.js 18+ installed
- Basic TypeScript knowledge
- Package manager (npm, yarn, or pnpm)
Installation
ESM-Only Framework
MoroJS is built for modern JavaScript and requires ESM (ES Modules). Make sure your project uses "type": "module" in package.json.
Install MoroJS using your preferred package manager:
npm
bash
yarn
bash
pnpm
bash
Create your project structure:
Create Your Project
bash
✓ What this does: Sets up a new project with ESM support and TypeScript configuration.
Your First API
Create a new file src/server.ts and add your first route:
src/server.ts
typescript
💡 Tip: Parameters are automatically typed. TypeScript knows params.id is a string.
Run Your API
Start the development server:
Start Development Server
bash
Test Your API
Your API is now running! Try these endpoints:
GET http://localhost:3000/GET http://localhost:3000/users/123
Add Type-Safe Validation
Now let's add validation to ensure type safety:
src/server.ts - With Validation
typescript
✨ Result: TypeScript automatically knows what properties are available. No type assertions needed!