Bootstrap Go module + Cloudflare Worker build tooling (#21)
Initialize the Go module and the Go -> Cloudflare Workers (TinyGo/Wasm) build path, structured so `go test` and a local dev server run on plain Go without TinyGo, while the real Wasm entrypoint is isolated behind build tags. - go.mod/go.sum: module github.com/JMR-dev/LibreMail-Bug-Report-Ingest (Go 1.26), requiring github.com/syumai/workers. - internal/handler: build-tag-free core http.Handler (GET / and GET /healthz, JSON responses, 404/405 handling) with net/http/httptest unit tests. - cmd/devserver: plain net/http server mounting the core handler for local dev without TinyGo (listens on :8787, override with ADDR). - worker/main.go: Cloudflare Workers (Wasm) entrypoint behind //go:build js && wasm, wiring the same handler via github.com/syumai/workers; excluded from host builds/tests. - package.json + pnpm-lock.yaml + pnpm-workspace.yaml: wrangler dev dependency managed with pnpm, with toolchain build scripts approved. - wrangler.jsonc: name=libremail-bug-report-ingest, main=./build/worker.mjs, build via `pnpm run build` (TinyGo). - README: "Build & run locally" section with exact commands and the rationale for the TinyGo + syumai/workers path. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit was merged in pull request #21.
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
e93b6a2266
commit
499bf7f655
@@ -0,0 +1,28 @@
|
||||
// Command devserver runs the core bug-report ingest handler on a plain
|
||||
// net/http server for local development.
|
||||
//
|
||||
// It deliberately does not depend on TinyGo or the Cloudflare Workers runtime,
|
||||
// so `go run ./cmd/devserver` works with the standard Go toolchain and exercises
|
||||
// the exact same handler that the deployed Wasm Worker serves. It listens on
|
||||
// :8787 by default (matching wrangler dev's default port); override with ADDR.
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/JMR-dev/LibreMail-Bug-Report-Ingest/internal/handler"
|
||||
)
|
||||
|
||||
func main() {
|
||||
addr := os.Getenv("ADDR")
|
||||
if addr == "" {
|
||||
addr = ":8787"
|
||||
}
|
||||
|
||||
log.Printf("devserver listening on %s (try GET / and GET /healthz)", addr)
|
||||
if err := http.ListenAndServe(addr, handler.New()); err != nil {
|
||||
log.Fatalf("devserver: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user