Establish consistent patterns for API design, particularly for request/response formats and parameter structures. This improves predictability, type safety, and developer experience across the codebase.
Establish consistent patterns for API design, particularly for request/response formats and parameter structures. This improves predictability, type safety, and developer experience across the codebase.
For communication interfaces, use standardized payload structures:
{
type: 'success' | 'error',
data: any,
event: string
}
For method parameters, prefer explicit options objects over method chaining when configuration is complex:
// Preferred: explicit options
agent.log = (options) => {
if (options && options.snapshot === false) {
// handle configuration
}
}
// Instead of: method chaining
agent.snapshot(false).log()
This approach makes APIs more readable, self-documenting, and easier to extend without breaking existing functionality. Consistent patterns also enable better tooling support and type checking.
Enter the URL of a public GitHub repository