package main import ( "log" "os" "os/exec" "strings" "github.com/aziis98/lupus-lite/routes" "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/logger" "github.com/gofiber/fiber/v2/middleware/recover" ) func main() { mode := os.Getenv("MODE") app := fiber.New() server := routes.NewServer() app.Use(logger.New()) app.Use(recover.New()) // Static files app.Static("/", "./_frontend/dist") // Pages app.Route("/", server.Pages) // Api routes app.Route("/api", server.Api) if strings.HasPrefix(mode, "dev") { log.Printf(`Running dev server for frontend: "npm run dev"`) err := (exec.Command("sh", "-c", "cd _frontend/ && npm run dev").Start()) if err != nil { log.Fatal(err) } } log.Fatal(app.Listen(":4000")) }