Documentation: routes / blogIndex

Purpose: Serves blog index by reading, filtering, sorting posts from filesystem.
Lifecycle Role: GET handler for /blog route.
Dependencies:
Upstream:
  • ../utils/postFileUtils (getAllPosts)
Downstream:
  • index
Data Flow:
Inputs: Query param drafts (optional).
Outputs: Rendered HTML page with posts excerpts.
Side Effects: Reads filesystem synchronously or asynchronously.
Performance and Scalability:
Bottlenecks:
  • Filesystem read latency on large post counts.
  • No caching; blocking IO possible.
Concurrency: None noted.
Security and Stability:
Validation: Query param drafts validated for filtering.
Vulnerabilities:
  • Risk of exposing unpublished posts if misconfigured.
Architecture Assessment:
Coupling: Moderate; depends on postFileUtils.
Abstraction: Content rendering with direct file access.
Recommendations:
  • Cache posts in memory or external cache.
  • Pre-render static index pages.
  • Add pagination.
  • Strictly validate drafts param.