---
globs: app/api/**/*.ts
---

# API Routes Rules

1. Routes MUST only use services for data access
2. Routes MUST handle input validation
3. Routes MUST return typed responses
4. Routes MUST use proper error handling

Example of correct API route:

```typescript
import { MyService } from "@/services/my-service";

export async function GET(request: Request) {
  try {
    const service = new MyService(pool);
    const data = await service.getData();
    return Response.json(data);
  } catch (error) {
    return Response.error();
  }
}
```

❌ FORBIDDEN:

- Direct database queries
- Business logic implementation
- Untyped responses
