import { defineModule, defineRoute } from "../../shared/define-module"
import type {
  FeedAnalyticsQuery,
  FeedAnalyticsResponse,
  FeedClaimChallengeRequest,
  FeedClaimChallengeResponse,
  FeedClaimListQuery,
  FeedClaimListResponse,
  FeedClaimMessageRequest,
  FeedClaimMessageResponse,
  FeedGetQuery,
  FeedGetResponse,
  FeedRefreshRequest,
  FeedRefreshResponse,
  FeedResetRequest,
  FeedResetResponse,
} from "./types"

/**
 * Feeds module definition with nested routes
 */
export const feedsModule = defineModule({
  name: "feeds",
  prefix: "/feeds",
  routes: {
    // Basic feed operations
    get: defineRoute<FeedGetQuery, FeedGetResponse>("GET", "/"),

    refresh: defineRoute<FeedRefreshRequest, FeedRefreshResponse>(
      "POST",
      "/refresh",
    ),

    analytics: defineRoute<FeedAnalyticsQuery, FeedAnalyticsResponse>(
      "GET",
      "/analytics",
    ),

    reset: defineRoute<FeedResetRequest, FeedResetResponse>("POST", "/reset"),

    // Feed claiming operations (nested)
    claim: {
      challenge: defineRoute<
        FeedClaimChallengeRequest,
        FeedClaimChallengeResponse
      >("POST", "/claim/challenge"),

      list: defineRoute<FeedClaimListQuery, FeedClaimListResponse>(
        "GET",
        "/claim/list",
      ),

      message: defineRoute<FeedClaimMessageRequest, FeedClaimMessageResponse>(
        "POST",
        "/claim/message",
      ),
    },
  },
})

// Export the API type
export type FeedsAPI = typeof feedsModule.api
