Skip to content
Back to skills

Api Endpoint

ASecurity

Create or modify API endpoints in IdeaForge backend. Triggers: new route, controller, service, repository, CRUD operation, Zod validation, API debugging. Pattern: Routes → Controller → Service → Repository.

  • 57 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
code-qualitytypescriptexpressdebuggingapidatabasebackend

Works with

  • api

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add diegosouzapw/awesome-omni-skill --skill api-endpoint --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Endpoint?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Endpoint
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/diegosouzapw-api-endpoint/badge)](https://www.skillsdirectory.com/skills/diegosouzapw-api-endpoint)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-endpoint
description: Create or modify API endpoints in IdeaForge backend. Triggers: new route, controller, service, repository, CRUD operation, Zod validation, API debugging. Pattern: Routes → Controller → Service → Repository.
---

# API Endpoints

## Architecture

```
Route (backend/src/api/routes/)     → DI setup + routing
Controller (backend/src/api/controllers/) → Zod validation + ApiResponse
Service (backend/src/services/)     → Business logic
Repository (backend/src/repositories/) → Database queries
```

## Quick Start

### 1. Route (`routes/{resource}.ts`)
```typescript
import { Router } from 'express';
const router = Router();

// Manual DI
const repo = new MyRepository();
const service = new MyService(repo);
const controller = new MyController(service);

router.get('/', (req, res, next) => controller.getAll(req, res, next));
router.post('/', (req, res, next) => controller.create(req, res, next));

export default router;
```

### 2. Controller (`controllers/{resource}Controller.ts`)
```typescript
const CreateSchema = z.object({
  name: z.string().min(1).max(255),
});

export class MyController {
  constructor(private service: MyService) {}

  async create(req: Request, res: Response, next: NextFunction) {
    try {
      const data = CreateSchema.parse(req.body);
      const result = await this.service.create(data);
      res.json({ success: true, data: result } as ApiResponse<typeof result>);
    } catch (error) {
      next(error);
    }
  }
}
```

### 3. Register (`index.ts`)
```typescript
import myRouter from './api/routes/my';
app.use('/api/my-resource', myRouter);
```

## Response Format

```typescript
// Success
{ success: true, data: { ... } }

// Error (via errorHandler middleware)
{ success: false, error: { message: "...", code: "ERROR_CODE" } }
```

## Rules

1. Controllers: validation + response only
2. Services: all business logic
3. Always use `ApiResponse<T>` wrapper
4. Always `next(error)` - never catch and format
5. Zod for all input validation
6. Manual DI in route files

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.