foundary-test-1770625554/services/studio-api/cmd/server/main.go
jordan a96587c022
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add components: app-react/studio-ui, service/studio-api
2026-02-09 08:27:48 +00:00

51 lines
1.4 KiB
Go

// Package main is the entry point for the studio-api service.
package main
import (
"flag"
"fmt"
"os"
"git.threesix.ai/jordan/foundary-test-1770625554/pkg/app"
"git.threesix.ai/jordan/foundary-test-1770625554/pkg/logging"
"git.threesix.ai/jordan/foundary-test-1770625554/services/studio-api/internal/adapter/memory"
"git.threesix.ai/jordan/foundary-test-1770625554/services/studio-api/internal/api"
"git.threesix.ai/jordan/foundary-test-1770625554/services/studio-api/internal/service"
)
func main() {
// Parse flags
exportOpenAPI := flag.Bool("export-openapi", false, "Export OpenAPI spec to stdout and exit")
flag.Parse()
// If exporting OpenAPI, generate spec and exit (used by CI for docs generation)
if *exportOpenAPI {
spec := api.NewServiceSpec()
jsonBytes, err := spec.JSON()
if err != nil {
fmt.Fprintf(os.Stderr, "failed to generate OpenAPI spec: %v\n", err)
os.Exit(1)
}
fmt.Println(string(jsonBytes))
os.Exit(0)
}
// Create logger
logger := logging.Default()
// Create adapters (repositories)
exampleRepo := memory.NewExampleRepository()
// Create services (business logic)
exampleService := service.NewExampleService(exampleRepo, logger)
// Create application
application := app.New("studio-api", app.WithDefaultPort(8001))
// Register routes with dependency injection
api.RegisterRoutes(application, exampleService)
// Start server
application.Run()
}