- Use Google Distroless images for all services (Go & Node.js). - Standardize documentation with [PROJECT-NAME].md. - Add .dockerignore and .gitignore to all projects. - Remove docker-compose.yml in favor of docker run instructions. - Fix Go version and dependency issues in observability, repo-integrations, and security-governance. - Add Podman support (fully qualified image names). - Update Dashboard to use Node.js static server for Distroless compatibility.
49 lines
No EOL
1.2 KiB
Go
49 lines
No EOL
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/go-chi/chi/v5/middleware"
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
"github.com/lab/repo-integrations-core/internal/api"
|
|
"github.com/lab/repo-integrations-core/internal/config"
|
|
"github.com/lab/repo-integrations-core/internal/db"
|
|
)
|
|
|
|
func main() {
|
|
cfg := config.Load()
|
|
|
|
pool, err := pgxpool.New(context.Background(), cfg.DatabaseURL)
|
|
if err != nil {
|
|
log.Fatalf("Unable to connect to database: %v\n", err)
|
|
}
|
|
defer pool.Close()
|
|
|
|
queries := db.New(pool)
|
|
apiHandler := api.New(cfg, queries)
|
|
|
|
r := chi.NewRouter()
|
|
r.Use(middleware.Logger)
|
|
r.Use(middleware.Recoverer)
|
|
|
|
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Write([]byte("Repo Integrations Core"))
|
|
})
|
|
|
|
r.Route("/integrations/github", func(r chi.Router) {
|
|
r.Get("/connect", apiHandler.ConnectGithubHandler)
|
|
r.Get("/callback", apiHandler.ConnectGithubCallbackHandler)
|
|
})
|
|
|
|
r.Post("/webhooks/github", apiHandler.GithubWebhookHandler)
|
|
|
|
r.Get("/repositories", apiHandler.ListRepositoriesHandler)
|
|
|
|
log.Println("Starting server on :8080")
|
|
if err := http.ListenAndServe(":8080", r); err != nil {
|
|
log.Fatalf("Could not start server: %s\n", err)
|
|
}
|
|
} |