Mock Api
Ecosistema completo para organización y gestión de contenido con interfaces espaciales
@gograb-space/mock-api Documentation
Complete documentation for the mock-api library, optimized for AI code generators and developers.
📖 Documentation Structure
📋 README
Main documentation with quick start guide, core concepts, and basic usage patterns. Perfect for getting started and understanding the library fundamentals.
Key Sections:
- 🚀 Quick Start for AI Code Generators
- 📚 Core API Reference
- 🛠️ Advanced Features
- 🔧 Common Patterns for AI Generation
- 📋 Code Generation Templates
🔍 API Reference
Comprehensive reference for all types, interfaces, services, and utilities in the library.
Contents:
- Core Types (MockRequest, MockResponse, MockHandler, MockDefinition)
- Configuration Types (GlobalInterceptorConfig, LoggingConfig, PersistenceConfig)
- Services (MockInterceptorUtilsService, MockInterceptorConfig)
- Utility Classes (DataGenerator, RouteMatcher, MockValidator, MiddlewareFactory)
- Statistics and Error Types
🎯 Generation Patterns
Specific patterns and templates optimized for AI code generators creating mock APIs.
Templates:
- Basic Entity Mock Template
- Service Integration Template
- Component Integration Template
- Relationship-Aware Mock Template
- Filtered Search Mock Template
- Authentication-Aware Mock Template
🚀 Quick Navigation
For AI Code Generators
- Start with README - Quick Start
- Use Generation Patterns for templates
- Reference API Reference for types and interfaces
For Developers
- Begin with README for overview and setup
- Explore Advanced Features for complex scenarios
- Check API Reference for detailed documentation
For Integration
- Review Common Patterns
- Use Integration Examples
- Follow Code Generation Templates
📝 Key Features Summary
✅ Core Capabilities
- HTTP Interceptor: Full Angular 20 integration with
provideHttpClient - Type-Safe Routes: Dynamic parameters, wildcards, and query params
- RxJS Support: Handlers can return Observables, Promises, or sync values
- Intelligent Storage: Optional persistence with IndexedDB, LocalStorage, or Memory
- Middleware System: Pre/post processing and error handling
- Data Generation: Realistic mock data generation utilities
✅ AI-Optimized Features
- Template-Driven: Ready-to-use patterns for common scenarios
- Convention-Based: Consistent naming and structure conventions
- Error-Friendly: Comprehensive error handling patterns
- Scalable: Patterns for simple to complex entity relationships
🎯 Common Use Cases
Development
// Quick mock setup for frontend development
const config = { enabled: true, fallbackToNetwork: false };
const mocks = { ...UsersMock, ...ProductsMock };
mockUtils.configureMockInterceptor(config, mocks);
Testing
// Minimal, predictable mocks for testing
const testMocks = {
'GET /api/users/1': () => ({ status: 200, data: { id: 1, name: 'Test User' } })
};
Prototyping
// Rich data for demos and prototypes
const demoMocks = createCrudMocks('Product', '/api/products',
() => generator.generateProduct(), initialProducts);
🔗 Related Libraries
This mock-api library integrates with other @gograb-space libraries:
- @gograb-space/utilities - Base utilities for data manipulation
- @gograb-space/log-system - Comprehensive logging integration
- @gograb-space/event-system - Event-driven architecture support
- @gograb-space/security - Authentication and authorization patterns
🛠️ Development Commands
# Build the library
npx nx build mock-api
# Run tests
npx nx test mock-api
# Run lint
npx nx lint mock-api
# Serve example app
npx nx serve gograb-space
📄 License
Part of the GoGrab Space monorepo - see main repository for license information.
🤝 Contributing
This documentation is optimized for AI code generators. When contributing:
- Maintain template consistency in generation-patterns.md
- Keep API reference up-to-date with code changes
- Ensure examples are copy-paste ready
- Follow established naming conventions
- Include both TypeScript types and usage examples
📞 Support
For issues, questions, or contributions related to the mock-api library:
- Check existing documentation first
- Review the API reference for type definitions
- Look at generation patterns for common use cases
- Refer to the main GoGrab Space repository for general issues