Skip to content

v2: Refactor to graph-based dependency injection with modular node architecture

Latest

Choose a tag to compare

@grindlemire grindlemire released this 29 Nov 17:52
· 1 commit to main since this release
v2.0.0
321b0d6

Summary

This is a major refactor that introduces graft as a dependency injection framework, restructuring the server into composable, dependency-aware nodes. The v1 pattern remains available via the v1 branch/tag for users who prefer a simpler, non-DI approach.

Changes

Architecture

  • New pkg/nodes/ package - Modular node-based architecture replacing the monolithic pkg/server/:
    • config/ - Environment configuration as a cacheable graft node
    • router/ - Echo router setup with middleware and route registration
    • server/ - HTTP server with explicit dependencies on config and router nodes
  • Deleted pkg/server/ - Replaced by the nodes architecture

Bootstrap

  • Simplified cmd/main.go using graft.ExecuteFor[server.Output]() to bootstrap the entire dependency graph
  • Cleaner signal handling and graceful shutdown

Auth & Error Handling

  • New web/pages/authfail/ - Dedicated unauthorized page template
  • Enhanced error handler renders the authfail page for 401 responses
  • Auth middleware demonstrates rejection flow with ?username=reject

Dependencies

  • Added github.com/grindlemire/graft for dependency injection

Breaking Changes

The internal structure is significantly different from v1. If you've built on top of v1:

  • pkg/server/ no longer exists - migrate to pkg/nodes/ pattern
  • Server bootstrap now uses graft's node execution model

Migration

For users who prefer the simpler v1 pattern without DI:
git clone --branch v1 https://github.com/grindlemire/gothem-stack.git