Bootstrap copied BFF and local accounts with public Sendico contracts (#34)

This commit is contained in:
Stephan D committed 2026-09-12 13:37:48 +02:00
1 parent 67dc5b5b1e
commit 7062672a87
556 files changed
+42291 -777

No files matched your search

+11 -36
View File
@@ -1,46 +1,21 @@
// Adapted from Sendico api/edge/product/main.go; see PROVENANCE.md.
package main
import (
"context"
"errors"
"log/slog"
"net/http"
"git.sendico.io/tech/sxchnge/bff/edge/shared/appversion"
"git.sendico.io/tech/sxchnge/bff/edge/shared/server"
"git.sendico.io/tech/sxchnge/bff/internal/profile"
"git.sendico.io/tech/sxchnge/bff/pkg/mlogger"
application "git.sendico.io/tech/sxchnge/bff/pkg/server"
smain "git.sendico.io/tech/sxchnge/bff/pkg/server/main"
"os"
"os/signal"
"syscall"
"time"
"git.sendico.io/tech/sxchnge/bff/internal/httpapi"
)
func factory(logger mlogger.Logger, file string, debug bool) (application.Application, error) {
return server.Create(logger, file, debug, profile.Runtime())
}
func main() {
if err := run(); err != nil {
slog.Error("BFF stopped", "error", err)
if smain.RunServer("sxchnge.bff", appversion.Create(), factory) != nil {
os.Exit(1)
}
}
func run() error {
addr := os.Getenv("SXCHNGE_HTTP_ADDR")
if addr == "" {
addr = "127.0.0.1:8082"
}
server := &http.Server{Addr: addr, Handler: httpapi.New(), ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 15 * time.Second, WriteTimeout: 15 * time.Second, IdleTimeout: 60 * time.Second, MaxHeaderBytes: 1 << 20}
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
failures := make(chan error, 1)
go func() { failures <- server.ListenAndServe() }()
slog.Info("BFF operational shell starting", "address", addr, "provider_configured", false)
select {
case err := <-failures:
if errors.Is(err, http.ErrServerClosed) {
return nil
}
return err
case <-ctx.Done():
shutdown, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
slog.Info("BFF shutting down")
return server.Shutdown(shutdown)
}
}