Add registry, ingest, timeline, tickets features
This commit is contained in:
@@ -2,19 +2,60 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"reanimator/internal/ingest"
|
||||
"reanimator/internal/repository/registry"
|
||||
"reanimator/internal/repository/tickets"
|
||||
"reanimator/internal/repository/timeline"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
httpServer *http.Server
|
||||
}
|
||||
|
||||
func NewServer(addr string, readTimeout, writeTimeout time.Duration) *Server {
|
||||
func NewServer(addr string, readTimeout, writeTimeout time.Duration, db *sql.DB) *Server {
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/health", healthHandler)
|
||||
|
||||
if db != nil {
|
||||
ticketRepo := tickets.NewTicketRepository(db)
|
||||
assetRepo := registry.NewAssetRepository(db)
|
||||
componentRepo := registry.NewComponentRepository(db)
|
||||
installationRepo := registry.NewInstallationRepository(db)
|
||||
timelineRepo := timeline.NewEventRepository(db)
|
||||
|
||||
RegisterRegistryRoutes(mux, RegistryDependencies{
|
||||
Customers: registry.NewCustomerRepository(db),
|
||||
Projects: registry.NewProjectRepository(db),
|
||||
Assets: assetRepo,
|
||||
Components: componentRepo,
|
||||
})
|
||||
RegisterIngestRoutes(mux, IngestDependencies{
|
||||
Service: ingest.NewService(db),
|
||||
})
|
||||
RegisterAssetComponentRoutes(mux, AssetComponentDependencies{
|
||||
Assets: assetRepo,
|
||||
Components: componentRepo,
|
||||
Installations: installationRepo,
|
||||
Tickets: ticketRepo,
|
||||
Timeline: timelineRepo,
|
||||
})
|
||||
RegisterTicketRoutes(mux, TicketDependencies{
|
||||
Tickets: ticketRepo,
|
||||
Assets: assetRepo,
|
||||
})
|
||||
RegisterUIRoutes(mux, UIDependencies{
|
||||
Assets: assetRepo,
|
||||
Installations: installationRepo,
|
||||
Timeline: timelineRepo,
|
||||
Tickets: ticketRepo,
|
||||
})
|
||||
}
|
||||
|
||||
return &Server{
|
||||
httpServer: &http.Server{
|
||||
Addr: addr,
|
||||
|
||||
Reference in New Issue
Block a user