mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-27 23:06:54 +05:00
Add @puaros/guardian package v0.1.0 - code quality guardian for vibe coders and enterprise teams. Features: - Hardcode detection (magic numbers, magic strings) - Circular dependency detection - Naming convention enforcement (Clean Architecture) - Architecture violation detection - CLI tool with comprehensive reporting - 159 tests with 80%+ coverage - Smart suggestions for fixes - Built for AI-assisted development Built with Clean Architecture and DDD principles. Works with Claude, GPT, Copilot, Cursor, and any AI coding assistant.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { CreateUser } from "../../application/use-cases/CreateUser"
|
|
import { CreateUserRequest } from "../../application/dtos/CreateUserRequest"
|
|
import { UserResponseDto } from "../../application/dtos/UserResponseDto"
|
|
|
|
/**
|
|
* User Controller
|
|
*
|
|
* Clean Architecture: Infrastructure / Presentation Layer
|
|
* - HTTP concerns (not in use case)
|
|
* - Request/Response handling
|
|
* - Error handling
|
|
* - Delegates to use cases
|
|
*
|
|
* SOLID Principles:
|
|
* - SRP: HTTP handling only
|
|
* - DIP: depends on use case abstraction
|
|
* - OCP: can add new endpoints
|
|
*
|
|
* Important:
|
|
* - NO business logic here
|
|
* - NO domain entities exposed
|
|
* - Returns DTOs only
|
|
* - Use cases do the work
|
|
*/
|
|
export class UserController {
|
|
constructor(private readonly createUser: CreateUser) {}
|
|
|
|
/**
|
|
* POST /users
|
|
*
|
|
* Clean Code:
|
|
* - Returns DTO, not domain entity
|
|
* - Delegates to use case
|
|
* - Focused method
|
|
*/
|
|
public async createUser(request: CreateUserRequest): Promise<UserResponseDto> {
|
|
try {
|
|
return await this.createUser.execute(request)
|
|
} catch (error) {
|
|
if (error instanceof Error) {
|
|
throw new Error(`Failed to create user: ${error.message}`)
|
|
}
|
|
throw error
|
|
}
|
|
}
|
|
}
|