refactor: replace via framework with chi + templ + datastar
Some checks failed
CI / Deploy / test (pull_request) Successful in 28s
CI / Deploy / lint (pull_request) Failing after 42s
CI / Deploy / deploy (pull_request) Has been skipped

Migrate from the via meta-framework to direct dependencies:
- chi for routing, templ for HTML templates, datastar for SSE/reactivity
- Feature-sliced architecture (features/{auth,lobby,c4game,snakegame}/)
- Shared layouts and components (features/common/)
- Handler factory pattern (HandleX(deps) http.HandlerFunc)
- Embedded NATS server (nats/), SCS sessions (sessions/), chi router wiring (router/)
- Move ChatMessage domain type from ui package to game package
- Remove old ui/ package (gomponents-based via/h views)
- Remove via dependency from go.mod entirely
This commit is contained in:
Ryan Hamamura
2026-03-02 12:16:25 -10:00
parent 2df20c2840
commit 8c3b3fc6ea
42 changed files with 5519 additions and 1891 deletions

29
features/c4game/routes.go Normal file
View File

@@ -0,0 +1,29 @@
package c4game
import (
"github.com/alexedwards/scs/v2"
"github.com/go-chi/chi/v5"
"github.com/nats-io/nats.go"
"github.com/ryanhamamura/c4/db"
"github.com/ryanhamamura/c4/game"
)
func SetupRoutes(
router chi.Router,
store *game.GameStore,
nc *nats.Conn,
sessions *scs.SessionManager,
chatPersister *db.ChatPersister,
) error {
router.Get("/game/{game_id}", HandleGamePage(store, sessions, chatPersister))
router.Get("/game/{game_id}/events", HandleGameEvents(store, nc, sessions, chatPersister))
router.Route("/api/game/{game_id}", func(r chi.Router) {
r.Post("/drop", HandleDropPiece(store, sessions))
r.Post("/chat", HandleSendChat(store, nc, sessions, chatPersister))
r.Post("/join", HandleSetNickname(store, sessions))
r.Post("/rematch", HandleRematch(store, sessions))
})
return nil
}