mirror of
https://github.com/samiyev/puaros.git
synced 2025-12-28 07:16:53 +05:00
feat(guardian): add guardian package - code quality analyzer
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.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { PlaceOrder, PlaceOrderRequest } from "../../application/use-cases/PlaceOrder"
|
||||
import { OrderResponseDto } from "../../application/dtos/OrderResponseDto"
|
||||
|
||||
/**
|
||||
* Order Controller
|
||||
*
|
||||
* Infrastructure Layer: HTTP Controller
|
||||
* - No business logic
|
||||
* - Returns DTOs (not domain entities!)
|
||||
* - Delegates to use cases
|
||||
*/
|
||||
export class OrderController {
|
||||
constructor(private readonly placeOrder: PlaceOrder) {}
|
||||
|
||||
/**
|
||||
* POST /orders
|
||||
*
|
||||
* ✅ Good: Returns DTO
|
||||
* ✅ Good: Delegates to use case
|
||||
* ✅ Good: No business logic
|
||||
*/
|
||||
public async placeOrder(request: PlaceOrderRequest): Promise<OrderResponseDto> {
|
||||
try {
|
||||
return await this.placeOrder.execute(request)
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(`Failed to place order: ${error.message}`)
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user