feat: add fullstack deployment and oracle app

This commit is contained in:
2026-04-28 13:35:53 +08:00
commit 57fbcf16d4
42 changed files with 7566 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
package main
import (
"log"
"net/http"
"time"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"xly/server/internal/config"
"xly/server/internal/handler"
"xly/server/internal/service"
)
func main() {
if err := godotenv.Load(".env"); err != nil {
log.Printf("skip .env load: %v", err)
}
cfg := config.Load()
router := gin.New()
router.Use(gin.Logger(), gin.Recovery())
if err := router.SetTrustedProxies(nil); err != nil {
log.Fatalf("set trusted proxies: %v", err)
}
router.Use(cors.New(cors.Config{
AllowOrigins: cfg.AllowedOrigins,
AllowMethods: []string{http.MethodGet, http.MethodPost, http.MethodOptions},
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
MaxAge: 12 * time.Hour,
}))
aiService := service.NewAIService(cfg)
httpHandler := handler.NewHTTPHandler(aiService)
httpHandler.Register(router)
address := ":" + cfg.Port
log.Printf("xly server listening on %s", address)
if err := router.Run(address); err != nil {
log.Fatalf("start gin server: %v", err)
}
}