Technical Documentation

API Reference & System Architecture

Comprehensive technical documentation for developers working with MoroJS internals, contributing to the framework, or building advanced integrations.

What's Inside

TypeScript-First Design

Full Type Safety

Complete type inference

typescript

1import { createApp } from '@morojs/moro';
2import { z } from 'zod';
3
4const app = createApp();
5
6const UserSchema = z.object({
7  name: z.string(),
8  email: z.string().email()
9});
10
11// Full TypeScript inference
12app.post('/users', {
13  body: UserSchema,
14  handler: ({ body }) => {
15    // body is typed as { name: string; email: string }
16    return { user: body };
17  }
18});

Advanced Types

Type utilities and inference

typescript

1// Extract types from schemas
2type User = z.infer<typeof UserSchema>;
3
4// Route handler types
5type Handler<T = any> = (context: {
6  body: T;
7  params: Record<string, string>;
8  query: Record<string, string>;
9}) => any;
10
11// Middleware types with proper inference
12type Middleware = (
13  req: Request,
14  res: Response,
15  next: NextFunction
16) => void | Promise<void>;

System Architecture

Core Components

Runtime System

  • • Multi-runtime adapter pattern
  • • Request/Response abstraction
  • • Environment detection
  • • Performance optimization

Middleware Pipeline

  • • Automatic ordering
  • • Type-safe composition
  • • Error boundary handling
  • • Performance monitoring

Type System

  • • Schema-driven validation
  • • Complete type inference
  • • Runtime type checking
  • • Developer experience

Ready to Dive Deep?

Explore the complete technical documentation to understand MoroJS internals, contribute to the framework, or build advanced integrations.