Best Practices โ
Production-ready patterns, security guidelines, and optimization strategies for building robust Ignis applications. These best practices are distilled from real-world experience building enterprise applications.
Architecture
Layered architecture, DI, components, lifecycle hooks
Code Standards
Naming, types, patterns, ESLint, Prettier
Security
Auth, validation, secrets, CORS, rate limiting
Data Modeling
Schemas, enrichers, relations, migrations
Testing
Unit tests, integration tests, mocking
Performance
Query optimization, caching, pooling
Error Handling
Error patterns, logging, user-friendly messages
Deployment
Docker, Kubernetes, cloud platforms, CI/CD
Learning Path โ
Foundation
Architecture โ Decisions Guide โ Code Standards
Understand patterns and establish coding conventionsData Layer
Data Modeling โ API Patterns โ Error Handling
Design your data layer and handle edge casesQuality Assurance
Testing โ Avoid Pitfalls โ Troubleshooting
Write tests and prevent common mistakesProduction Ready
Security โ Performance โ Deployment
Secure, optimize, and deploy your applicationQuick Reference โ
Essential Patterns โ
// โ
Layered Architecture
Controller โ Service โ Repository โ DataSource
// โ
Dependency Injection
@inject({ key: BindingKeys.build({ namespace: BindingNamespaces.SERVICE, key: UserService.name }) })
// โ
Error Handling
throw getError({ statusCode: 404, message: 'User not found' });
// โ
Input Validation
request: { body: jsonContent({ schema: z.object({ email: z.string().email() }) }) }Anti-Patterns to Avoid โ
// โ Business logic in controllers
@get({ configs: RouteConfigs.GET_USER })
async getUser(c: Context) {
const user = await this.userRepo.findById(id);
if (user.lastLogin < cutoff) await this.sendReminder(user); // Move to service!
return c.json(user);
}
// โ Catching all errors silently
try { await riskyOperation(); } catch (e) { /* swallowed */ }
// โ Using `any` type
const data: any = await fetchData(); // Use proper types!Security Checklist โ
| Check | Action |
|---|---|
| Secrets | Store in environment variables, never in code |
| Input | Validate with Zod schemas at API boundaries |
| Auth | Protect routes with authStrategies: [Authentication.STRATEGY_JWT] |
| Sensitive data | Use hiddenProperties in model settings |
| File uploads | Use sanitizeFilename() for all user-provided filenames |
| CORS | Configure allowed origins explicitly |
Performance Checklist โ
| Check | Action |
|---|---|
| Queries | Use fields to select only needed columns |
| Pagination | Always set limit on find operations |
| Relations | Limit include depth to 2 levels max |
| Connection pool | Configure pool size based on load |
| Background jobs | Offload CPU-intensive tasks to workers |
| Caching | Cache expensive queries with Redis |
All Best Practices โ
Architecture & Design โ
| Guide | Description |
|---|---|
| Architectural Patterns | Layered architecture, DI, components, mixins |
| Architecture Decisions | When to use services, repositories, components |
Development โ
| Guide | Description |
|---|---|
| Code Style Standards | Naming conventions, types, ESLint, Prettier |
| Data Modeling | Schema design, enrichers, relations, migrations |
| API Usage Examples | Routing, repositories, middleware, services |
Quality โ
| Guide | Description |
|---|---|
| Testing Strategies | Unit tests, integration tests, mocking, E2E |
| Error Handling | Error patterns, structured errors, logging |
| Common Pitfalls | Mistakes to avoid and how to fix them |
| Troubleshooting Tips | Debug common issues quickly |
Production โ
| Guide | Description |
|---|---|
| Security Guidelines | Authentication, validation, secrets, CORS |
| Performance Optimization | Query optimization, caching, connection pooling |
| Deployment Strategies | Docker, Kubernetes, cloud platforms, CI/CD |
Contributing โ
| Guide | Description |
|---|---|
| Contribution Workflow | Git workflow, PR guidelines, code review |
New to Ignis?
Start with the Getting Started Guide for tutorials, then return here for production-ready patterns.
Production Deployment?
Before deploying, review the Security Guidelines and Deployment Strategies thoroughly.
See Also โ
- Getting Started - New to Ignis? Start here
- API Reference - Detailed API documentation
- Core Concepts - Deep dive into architecture
- Changelogs - Version history and updates