organized api packages into a unified constructor
This commit is contained in:
@@ -13,19 +13,13 @@ import (
|
||||
etsy_platform "ruben/inventory2/internal/domains/platforms/etsy"
|
||||
"ruben/inventory2/internal/domains/raw_events"
|
||||
"ruben/inventory2/internal/logging"
|
||||
accounts_api "ruben/inventory2/internal/server/api/accounts"
|
||||
auth_api "ruben/inventory2/internal/server/api/auth"
|
||||
sse_api "ruben/inventory2/internal/server/api/sse"
|
||||
"ruben/inventory2/internal/server/api"
|
||||
templates_api "ruben/inventory2/internal/server/api/templates"
|
||||
"ruben/inventory2/internal/server/api/webhooks"
|
||||
etsy_webhooks "ruben/inventory2/internal/server/api/webhooks/etsy"
|
||||
"ruben/inventory2/internal/server/middleware"
|
||||
"ruben/inventory2/internal/server/response"
|
||||
"ruben/inventory2/internal/server/sse"
|
||||
)
|
||||
|
||||
// r gin.IRouter, // TODO: use this everywhere
|
||||
|
||||
type Router struct {
|
||||
*gin.Engine
|
||||
sse *sse.Queue
|
||||
@@ -84,9 +78,6 @@ func NewRouter(
|
||||
|
||||
// api endpoints
|
||||
|
||||
api := r.Group("/api")
|
||||
apiLogger := logger.WithGroup("/api")
|
||||
|
||||
// sse setup
|
||||
sq := sse.NewQueue()
|
||||
unp := middleware.NewUpdateNotificationPublisher(
|
||||
@@ -94,33 +85,15 @@ func NewRouter(
|
||||
sq,
|
||||
).Trim("/api")
|
||||
|
||||
// TODO: group these into a single unifieds 'apis' object/package?
|
||||
auth_api.Routes(
|
||||
api.Group("/auth"),
|
||||
apiLogger.WithGroup("/auth"),
|
||||
auth,
|
||||
)
|
||||
sse_api.Routes(
|
||||
api.Group("/events", authM.Authenticate()),
|
||||
apiLogger.WithGroup("/events"),
|
||||
api.Routes(
|
||||
r.Group("/api"),
|
||||
logger.WithGroup("/api"),
|
||||
authM,
|
||||
sq,
|
||||
)
|
||||
accounts_api.Routes(
|
||||
api.Group("/accounts", authM.Authenticate()),
|
||||
apiLogger.WithGroup("/accounts"),
|
||||
accts,
|
||||
unp.Group("/accounts"),
|
||||
)
|
||||
webhooks.Routes(
|
||||
api.Group("/webhooks"),
|
||||
apiLogger.WithGroup("/webhooks"),
|
||||
unp,
|
||||
rawEvents,
|
||||
etsy,
|
||||
webhooks.Config{
|
||||
Etsy: etsy_webhooks.Config{
|
||||
OAuthRedirectURIWithAcctIDParam: "/oauth/accounts/:acctID/auth_code",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
return &Router{
|
||||
|
||||
Reference in New Issue
Block a user