41 lines
663 B
Go
41 lines
663 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/joho/godotenv"
|
|
"stereo.cat/backend/internal/api"
|
|
"stereo.cat/backend/internal/types"
|
|
)
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if value, ok := os.LookupEnv(key); ok {
|
|
return value
|
|
}
|
|
return fallback
|
|
}
|
|
|
|
func main() {
|
|
_ = godotenv.Load()
|
|
|
|
imagePath := getEnv("IMAGE_PATH", os.TempDir())
|
|
|
|
if _, err := os.Stat(imagePath); err != nil {
|
|
if os.IsNotExist(err) {
|
|
if err := os.MkdirAll(imagePath, os.ModePerm); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
}
|
|
|
|
c := types.StereoConfig{
|
|
Router: gin.Default(),
|
|
ImagePath: imagePath,
|
|
}
|
|
|
|
api.Register(&c)
|
|
|
|
c.Router.Run()
|
|
}
|