first commit

This commit is contained in:
2026-02-17 17:15:39 -08:00
parent 1bf9c29f09
commit b70ea7e877
25 changed files with 4145 additions and 0 deletions

43
main.go Normal file
View File

@@ -0,0 +1,43 @@
package main
import (
"log"
"net/http"
"os"
"aroll/handlers"
"aroll/store"
"aroll/ws"
)
func main() {
redisAddr := "localhost:6379"
if addr := os.Getenv("REDIS_ADDR"); addr != "" {
redisAddr = addr
}
st, err := store.New(redisAddr)
if err != nil {
log.Fatalf("redis: %v", err)
}
log.Printf("Connected to Redis at %s", redisAddr)
hub := ws.NewHub()
go hub.Run()
mux := http.NewServeMux()
mux.HandleFunc("/ws", handlers.WSHandler(hub))
mux.HandleFunc("/upload", handlers.UploadHandler(st))
mux.HandleFunc("/analyze", handlers.AnalyzeHandler(st, hub))
mux.HandleFunc("/export", handlers.ExportHandler(st, hub))
mux.Handle("/download/", http.StripPrefix("/download/", handlers.DownloadHandler(st)))
// Serve the React build in production
if _, err := os.Stat("frontend/dist"); err == nil {
mux.Handle("/", http.FileServer(http.Dir("frontend/dist")))
}
log.Println("Listening on http://localhost:8080")
log.Fatal(http.ListenAndServe(":8080", mux))
}