- **feat(ui):** implement `AcknowledgeButton` component for acknowledging images - **feat(stats):** add dashboard stats for total images, pending updates, and acknowledged status - **chore(deps):** introduce `bun` dependency management and add required libraries - **style(ui):** enhance UI with Tailwind-based components and modularity improvements - **chore:** add drag-and-drop tag assignment using `@dnd-kit/core`
63 lines
1.4 KiB
Go
63 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
"time"
|
|
|
|
diun "awesomeProject/pkg/diunwebhook"
|
|
)
|
|
|
|
func main() {
|
|
if err := diun.InitDB("./diun.db"); err != nil {
|
|
log.Fatalf("InitDB: %v", err)
|
|
}
|
|
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("/webhook", diun.WebhookHandler)
|
|
mux.HandleFunc("/api/updates/", diun.DismissHandler)
|
|
mux.HandleFunc("/api/updates", diun.UpdatesHandler)
|
|
mux.HandleFunc("/api/tags", diun.TagsHandler)
|
|
mux.HandleFunc("/api/tags/", diun.TagByIDHandler)
|
|
mux.HandleFunc("/api/tag-assignments", diun.TagAssignmentHandler)
|
|
mux.Handle("/", http.FileServer(http.Dir("./frontend/dist")))
|
|
|
|
srv := &http.Server{
|
|
Addr: ":" + port,
|
|
Handler: mux,
|
|
ReadTimeout: 10 * time.Second,
|
|
WriteTimeout: 10 * time.Second,
|
|
IdleTimeout: 60 * time.Second,
|
|
}
|
|
|
|
stop := make(chan os.Signal, 1)
|
|
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
go func() {
|
|
log.Printf("Listening on :%s", port)
|
|
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
log.Fatalf("ListenAndServe: %v", err)
|
|
}
|
|
}()
|
|
|
|
<-stop
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
|
defer cancel()
|
|
|
|
if err := srv.Shutdown(ctx); err != nil {
|
|
log.Printf("Shutdown error: %v", err)
|
|
} else {
|
|
log.Println("Server stopped cleanly")
|
|
}
|
|
}
|