feat: complete phase 0

This commit is contained in:
Blake Ridgway
2026-04-24 19:49:13 -05:00
parent 0c1547e0d5
commit c1d8b17147
5 changed files with 71 additions and 9 deletions

16
Makefile Normal file
View File

@@ -0,0 +1,16 @@
BIN := bin/heloha-server
CMD := ./cmd/heloha-server
.PHONY: build run test tidy
build:
go build -o $(BIN) $(CMD)
run:
go run $(CMD)
test:
go test ./...
tidy:
go mod tidy

18
TODO.md
View File

@@ -12,21 +12,21 @@ A detailed, actionable task list for building a unified, multi-radar severe weat
- [x] `git init`
- [x] Create a `.gitignore` file for Go and common OS files.
- [x] Create a `README.md` with the project's mission statement.
- [ ] **Establish Go Project Structure:**
- [ ] `go mod init github.com/blakeridgway/heloha`
- [ ] Create a standard Go project layout:
- [x] **Establish Go Project Structure:**
- [x] `go mod init github.com/blakeridgway/heloha`
- [x] Create a standard Go project layout:
- `/cmd/heloha-server`: Main application entry point.
- `/internal/radar`: Code for fetching, parsing, and processing radar data.
- `/internal/server`: HTTP handlers and server logic.
- `/internal/config`: Configuration management.
- `/web/templates`: HTML templates for the frontend.
- `/web/static`: CSS and JavaScript assets.
- [ ] **Create a Basic Web Server:**
- [ ] In `/cmd/heloha-server/main.go`, set up an `http.Server`.
- [ ] Choose and implement a router (e.g., `go-chi/chi` is a good choice for middleware and flexibility).
- [ ] Create a simple `/healthz` endpoint that returns `200 OK`.
- [ ] **Set Up Build Automation:**
- [ ] Create a `Makefile` with targets for:
- [x] **Create a Basic Web Server:**
- [x] In `/cmd/heloha-server/main.go`, set up an `http.Server`.
- [x] Choose and implement a router (e.g., `go-chi/chi` is a good choice for middleware and flexibility).
- [x] Create a simple `/healthz` endpoint that returns `200 OK`.
- [x] **Set Up Build Automation:**
- [x] Create a `Makefile` with targets for:
- `build`: `go build -o bin/heloha-server ./cmd/heloha-server`
- `run`: `go run ./cmd/heloha-server`
- `test`: `go test ./...`

39
cmd/heloha-server/main.go Normal file
View File

@@ -0,0 +1,39 @@
package main
import (
"log/slog"
"net/http"
"os"
"time"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
r := chi.NewRouter()
r.Use(middleware.RequestID)
r.Use(middleware.RealIP)
r.Use(middleware.Recoverer)
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("ok"))
})
srv := &http.Server{
Addr: ":8080",
Handler: r,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
IdleTimeout: 120 * time.Second,
}
logger.Info("starting server", "addr", srv.Addr)
if err := srv.ListenAndServe(); err != nil {
logger.Error("server exited", "err", err)
os.Exit(1)
}
}

5
go.mod Normal file
View File

@@ -0,0 +1,5 @@
module github.com/blakeridgway/heloha
go 1.25.9
require github.com/go-chi/chi/v5 v5.2.5

2
go.sum Normal file
View File

@@ -0,0 +1,2 @@
github.com/go-chi/chi/v5 v5.2.5 h1:Eg4myHZBjyvJmAFjFvWgrqDTXFyOzjj7YIm3L3mu6Ug=
github.com/go-chi/chi/v5 v5.2.5/go.mod h1:X7Gx4mteadT3eDOMTsXzmI4/rwUpOwBHLpAfupzFJP0=