rewrite into go and nextjs

This commit is contained in:
2025-05-06 13:31:09 -07:00
commit e7b1090a85
14 changed files with 494 additions and 0 deletions

58
cmd/junk2jive/main.go Normal file
View File

@@ -0,0 +1,58 @@
package main
import (
"flag"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/config"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/handlers"
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/routes"
)
func main() {
// Parse command line flags
var configPath string
flag.StringVar(&configPath, "config", "", "Path to config file")
flag.Parse()
// If no config file specified, look for it in default locations
if configPath == "" {
// Check current directory
if _, err := os.Stat("config.json"); err == nil {
configPath = "config.json"
} else {
// Check config directory relative to executable
exePath, err := os.Executable()
if err == nil {
potentialPath := filepath.Join(filepath.Dir(exePath), "../config/config.json")
if _, err := os.Stat(potentialPath); err == nil {
configPath = potentialPath
}
}
}
}
// Load configuration
cfg, err := config.Load(configPath)
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
// Initialize services
// This would initialize your OpenAI and Robowflow services
// based on your configuration
// Set up the router
router := routes.SetupRoutes(cfg)
// Start the server
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
log.Printf("Starting server on %s", addr)
if err := http.ListenAndServe(addr, router); err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}