Design API endpoints with concise, direct naming that clearly communicates their purpose without unnecessary verbosity. Avoid redundant prefixes or overly descriptive names that make endpoints harder to remember and use. Choose built-in language features over custom implementations when possible to improve reliability and maintainability.
Design API endpoints with concise, direct naming that clearly communicates their purpose without unnecessary verbosity. Avoid redundant prefixes or overly descriptive names that make endpoints harder to remember and use. Choose built-in language features over custom implementations when possible to improve reliability and maintainability.
For endpoint naming, prefer the core functionality over implementation details:
// Avoid verbose prefixes
v1Router.post("/generate-llmstxt", ...) // โ Too verbose
// Prefer direct, clear naming
v1Router.post("/llmstxt", ...) // โ
Concise and clear
For implementation, leverage built-in APIs over custom logic:
// Avoid custom regex for URL handling
const isCompleteUrl = new RegExp('^(?:[a-z+]+:)?//', 'i');
if (!isCompleteUrl.test(link)){
link = this.baseUrl + link;
}
// Use built-in URL constructor
const url = new URL(link.trim(), this.baseUrl); // โ
Simpler and more reliable
This approach improves developer experience by making APIs more intuitive to use and implementations easier to understand and maintain.
Enter the URL of a public GitHub repository