How robintail/express-zod-api works
Main Components
a. Core Framework Components:
• EndpointsFactory
• ResultHandler
• Middleware System
• Router
• Documentation Generator
• Integration Generator
• Schema Validation Layer
b. External Dependencies:
• Express.js Server
• Zod Validation Library
• Logger Interface
• File Upload Handler
• Static File Server
┌─ API Layer ─────────────────────────────────────────┐
• Routes (Routing Tree) │
• Endpoints (GET/POST/PUT/DELETE) │
• Static File Serving │
• ┘
• ↓
┌─ Processing Layer ───────────────────────────────────┐
• ┌─ Request Pipeline ─┐ ┌─ Validation Layer ───────┐ │
• Input Sources │ │ Input Schema (Zod) │ │
• Middleware Chain │ │ Output Schema (Zod) │ │
• Error Handling │ │ Custom Types & Brands │ │
• ┘ └────────────────────────┘ │
• ┘
• ↓
┌─ Core Services Layer ────────────────────────────────┐
• ┌─ Handlers ────────┐ ┌─ Support Services ───────┐ │
• Result Handler │ │ Logger │ │
• Upload Handler │ │ Graceful Shutdown │ │
• SSE Handler │ │ CORS Handler │ │
• ┘ └────────────────────────┘ │
• ┘
• ↓
┌─ Integration Layer ─────────────────────────────────┐
• Documentation Generator (OpenAPI) │
• Frontend Client Generator │
• Type Definitions │
• ┘
Flow Indicators
• Request flow: Client → Router → Middleware → Handler → Response
• Validation flow: Input → Zod Schema → Handler → Output Schema → Response
• Integration flow: Endpoints → Documentation/Client Generation
Special Elements
• Schema validation showing Zod integration
• Middleware chain processing
• Error handling flow
• File upload processing
• SSE (Server-Sent Events) handling
Component Details
For each major component, include:
• Input/Output interfaces
• Key methods/functions
• Dependencies on other components
• Configuration options
Notes Section
Annotations for:
• Configuration options
• Security features
• Performance considerations
• Integration points
• The modular nature of the framework
• The central role of schema validation
• The middleware chain processing
• The flexibility in handling different types of requests
• The integration capabilities with frontend systems