Update structure to domain driven architecture.

This commit is contained in:
2026-05-08 08:14:25 +02:00
parent 4f3692abd9
commit 2993cc04ef
21 changed files with 185 additions and 103 deletions
+6 -6
View File
@@ -10,15 +10,15 @@ import (
"syscall"
"time"
"nfeeder/internal/db"
"nfeeder/internal/web"
"nfeeder/db"
"nfeeder/web"
"github.com/jackc/pgx/v5/pgxpool"
)
func main() {
// @Logger
// INFO: Logger
// ------------------------------------------------------------
var handler slog.Handler
if os.Getenv("ENV") == "production" {
@@ -31,7 +31,7 @@ func main() {
ctx, ctxCancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer ctxCancel()
// @DB
// INFO:DB
// ------------------------------------------------------------
connStr := os.Getenv("DATABASE_URL")
if connStr == "" {
@@ -67,7 +67,7 @@ func main() {
// Create Store sqlc wrapper
store := db.NewStore(pool)
// @Server
// INFO: Server
// ------------------------------------------------------------
jwtSecret := os.Getenv("JWT_SECRET")
if jwtSecret == "" {
@@ -87,7 +87,7 @@ func main() {
}
}()
// @GracefulShutdown
// INFO: GracefulShutdown
// ------------------------------------------------------------
<-ctx.Done()
logger.Warn("shutdown signal received", "signal", "SIGTERM/Interrupt")
+70
View File
@@ -0,0 +1,70 @@
package main
import (
"fmt"
"os"
tea "charm.land/bubbletea/v2"
)
type model struct {
name string
sayHello bool
}
func initialModel() model {
return model{
name: "jason",
sayHello: false,
}
}
func (m model) Init() tea.Cmd {
// any init commands like fetching data etc
// to populate model if need be
return nil
}
// Update loop like a game
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
// Handle key presses
case tea.KeyMsg:
switch msg.String() {
// Quit the app
case "ctrl+c", "q":
return m, tea.Quit
// Toggle the greeting
case "enter", " ":
m.sayHello = !m.sayHello
}
}
return m, nil
}
// View: Returns a string representing the UI. like a render method
func (m model) View() tea.View {
s := "nfeeder Dev Console\n"
s += "-------------------\n\n"
if m.sayHello {
s += fmt.Sprintf("Hello, %s! Nice to see you.\n\n", m.name)
} else {
s += "Press ENTER to say hello.\n\n"
}
s += "Press 'q' to quit.\n"
return tea.NewView(s)
}
func main() {
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
fmt.Printf("Alas, there's been an error: %v", err)
os.Exit(1)
}
}