• v1.0.0 fa04364413

    Rene Nochebuena released this 2026-06-02 13:08:33 -06:00 | 0 commits to main since this release

    v1.0.0

    code.nochebuena.dev/einherjar/spa-server


    Architecture Decisions Resolved

    Decision Outcome
    Module type Binary, not a library — produces a Docker base image; no consumer imports
    web dependency Excluded — plain net/http + core is sufficient; chi routing and middleware add no value for static file serving
    SPA fallback http.Dir.Open path sanitisation check before serving — prevents directory traversal without an extra dependency
    Directory listing Disabled — directory paths fall through to index.html; the SPA router owns all URL space
    Health format Matches web/health.Response wire format ({"status":"UP","components":{}}) without importing web
    Health status Always UP — no external dependencies to probe; process reachability is the only meaningful check
    Port binding Synchronous in OnStart via net.Listen before the goroutine — port conflicts surface immediately
    Config parsing os.Getenv with inline defaults — zero external dependencies, no caarlos0/env in the binary
    Base image alpine:3.21 with ca-certificates + tzdata — consistent with the rest of the iron-dough ecosystem
    Static dir default /srv/www — consumer Dockerfile does COPY dist/ /srv/www/ with no env var override needed

    API

    import spaserver "code.nochebuena.dev/einherjar/spa-server"
    
    // Config
    type Config struct {
        Port      int    // EINHERJAR_SPA_PORT       (default: 8080)
        StaticDir string // EINHERJAR_SPA_STATIC_DIR (default: /srv/www)
    }
    func DefaultConfig() Config
    
    // Server — implements lifecycle.Component
    type Server struct { /* unexported fields */ }
    func NewServer(logger logging.Logger, cfg Config) *Server
    func (s *Server) OnInit() error
    func (s *Server) OnStart() error
    func (s *Server) OnStop() error
    

    Docker image

    code.nochebuena.dev/einherjar/spa-server:v1.0.0
    code.nochebuena.dev/einherjar/spa-server:latest
    

    Build args:

    • VERSION — embedded at build time via -ldflags (default: dev)

    Dependencies

    Module Version Role
    code.nochebuena.dev/einherjar/contracts v1.0.0 lifecycle.Component, logging.Logger
    code.nochebuena.dev/einherjar/core v1.0.0 launcher, logz
    Downloads