Automating Dead Endpoint Detection: Deleting 16,000 Lines of Legacy Node.js Code
These articles are AI-generated summaries. Please check the original sources for full details.
How I automated dead endpoint detection and removed 16,000 lines from our Node.js codebase
Miguel Lopes developed an automated detection system to identify and prune unused endpoints in a legacy Express API. By cross-referencing access logs with registered routes, the team successfully deleted 16,000 lines of code, representing 35% of the total codebase.
Why This Matters
Static analysis tools like ESLint are insufficient for identifying dead endpoints because they only detect unreachable code, not the absence of live traffic. In legacy systems, this technical debt accumulates over years of product iterations, leading to bloated codebases that are difficult to refactor and slow to onboard new engineers.
Key Insights
- Production log ingestion: Miguel Lopes (2026) used access logs to extract routes receiving live traffic, providing a signal that static analysis cannot replicate.
- Automated route mapping: The system maps log data against every route registered in the Express application to identify discrepancies and identify candidates for removal.
- Metadata-driven verification: The detector ranks candidates by last-seen dates and call volume to help engineers distinguish between dead code and low-frequency internal jobs.
- The 12-month observation window: To avoid breaking legacy clients or quarterly tasks, a long-term verification checklist is used across production, staging, and canary environments.
- Impact of feature abandonment: Eight years of iterations resulted in a 45,000-line codebase where 50 endpoints were found to be completely unused.
Practical Applications
- Legacy API Pruning: Using the detector to rank endpoints by traffic volume and last-seen date before manual verification. Pitfall: Deleting endpoints that look dead but are actually triggered by infrequent internal scripts or quarterly jobs.
- Codebase Refactoring: Reducing the surface area of Express apps to improve maintenance speed. Pitfall: Relying purely on static analysis which results in ‘zombie’ code remaining in production.
References:
Continue reading
Next article
Resolving SpiderFoot Dependency Conflicts via Docker Containerization
Related Content
Automating Policy-Gated Releases: Building SwiftDeploy for Observable DevOps
SwiftDeploy evolves into a policy-gated system using OPA to block releases if disk space is under 10GB or error rates exceed 1%.
Dinghy: Unifying DevOps Tooling with a Single CLI and Docker Engine
Dinghy unifies infrastructure, diagrams, and docs into one CLI, allowing engineers to generate 248 lines of Terraform from just 8 lines of TSX source.
Why Continuous Integration Delivers Simultaneous Gains in Velocity and Quality
A 2015 study of 246 GitHub projects proves CI adoption breaks the speed-quality tradeoff, enabling faster merges and higher bug detection rates for core developers.