Skip to content

Test - #65

Merged
sweetmantech merged 14 commits into
mainfrom
test
Dec 15, 2025
Merged

Test#65
sweetmantech merged 14 commits into
mainfrom
test

Conversation

@sweetmantech

@sweetmantechsweetmantech commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Added account authentication API supporting API key and Bearer token authentication methods
    • Added YouTube tools: retrieve channel information, access revenue analytics, fetch video lists, and customize video thumbnails

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercelBot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentReviewUpdated (UTC)
recoup-apiReadyReadyPreviewDec 15, 2025 2:25pm

@coderabbitai

coderabbitaiBot commented Dec 15, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

This PR introduces a new authenticated account ID endpoint with API key and Bearer token support, adds comprehensive YouTube MCP tool integrations (channels, revenue, video list, thumbnail setter), and provides supporting utilities for YouTube Analytics queries, channel info fetching, image processing, and OAuth client management. Two npm dependencies (googleapis and sharp) are added.

Changes

Cohort / File(s)Summary
Account ID Endpoint & Auth Utilities
app/api/accounts/id/route.ts, lib/accounts/getAccountIdHandler.ts, lib/accounts/validateAccountIdHeaders.ts, lib/auth/getApiKeyAccountId.ts
New API route with GET and OPTIONS handlers; validates incoming requests via x-api-key or Bearer token; delegates to existing account ID resolution logic; returns 200 with account ID or 401/500 errors with CORS headers.
Database Query
lib/supabase/account_api_keys/selectAccountApiKeys.ts
New Supabase query utility to fetch account API keys by optional keyHash filter.
YouTube MCP Tool Registrations
lib/mcp/tools/youtube/index.ts, lib/mcp/tools/youtube/registerGetYouTubeChannelsTool.ts, lib/mcp/tools/youtube/registerGetYouTubeRevenueTool.ts, lib/mcp/tools/youtube/registerGetYouTubeChannelVideoListTool.ts, lib/mcp/tools/youtube/registerSetYouTubeThumbnailTool.ts
Registers four new YouTube MCP tools: get\_youtube\_channels, get\_youtube\_revenue, get\_youtube\_channel\_video\_list, set\_youtube\_thumbnail; validates inputs, manages token expiry, and delegates to YouTube API helpers.
YouTube API & Analytics Utilities
lib/youtube/oauth-client.ts, lib/youtube/createYouTubeAnalyticsClient.ts, lib/youtube/fetchYouTubeChannelInfo.ts, lib/youtube/getYoutubePlaylistVideos.ts, lib/youtube/queryAnalyticsReports.ts
OAuth2 client initialization; YouTube Analytics and Data API client setup; channel info fetching with optional branding; playlist video enumeration and details; revenue/analytics report querying.
YouTube Helper Functions
lib/youtube/getDefaultDateRange.ts, lib/youtube/getResizedImageBuffer.ts, lib/youtube/handleRevenueError.ts
Utility for 30-day default date range; image fetch, resize, and compression via sharp (max 2MB); standardized error message formatting for revenue queries.
Dependencies
package.json
Added googleapis@^168.0.0 and sharp@^0.34.5.

Sequence Diagram

sequenceDiagram
participant Client
participant API as GET /api/accounts/id
participant Validate as validateAccountIdHeaders
participant AuthPath as getAuthenticatedAccountId<br/>OR getApiKeyAccountId
participant Response
Client->>API: GET request with auth header<br/>(x-api-key or Bearer)
API->>Validate: forward request
Validate->>Validate: parse & verify exactly<br/>one auth method present
alt Auth validation fails
Validate->>Response: 401 + error
else Valid x-api-key
Validate->>AuthPath: delegate to getApiKeyAccountId
AuthPath->>AuthPath: hash key & query DB
alt Key found & valid
AuthPath->>Validate: return accountId
else Error
AuthPath->>Validate: return 401/500 error
end
else Valid Bearer token
Validate->>AuthPath: delegate to getAuthenticatedAccountId
AuthPath->>AuthPath: verify token with Privy
alt Token valid
AuthPath->>Validate: return accountId
else Error
AuthPath->>Validate: return 401/500 error
end
end
Validate->>API: return accountId or error
API->>Response: wrap with status & CORS headers
Response->>Client: 200 { status, accountId }<br/>or 401/500 { status, message }
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Key areas requiring extra attention:
    • lib/auth/getApiKeyAccountId.ts — hash-based key lookup and multi-step error handling chain
    • lib/youtube/queryAnalyticsReports.ts — YouTube Analytics API integration with channel ID validation and revenue aggregation logic
    • lib/youtube/getResizedImageBuffer.ts — image processing pipeline with conditional resize/compress and size rechecking
    • lib/mcp/tools/youtube/registerSetYouTubeThumbnailTool.ts — thumbnail upload flow combining image resize, client initialization, and API call
    • Cross-module token/auth dependency chain (validateAccountIdHeaders → getAuthenticatedAccountId / getApiKeyAccountId)

Possibly related PRs

Poem

🐰 With API keys and tokens held so tight,
YouTube channels shimmer in the light!
From thumbnails set to revenue high,
The rabbit's auth tools help workflows fly! 🚀✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d7ef63b and 4eec841.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • app/api/accounts/id/route.ts (1 hunks)
  • lib/accounts/getAccountIdHandler.ts (1 hunks)
  • lib/accounts/validateAccountIdHeaders.ts (1 hunks)
  • lib/auth/getApiKeyAccountId.ts (1 hunks)
  • lib/mcp/tools/youtube/index.ts (2 hunks)
  • lib/mcp/tools/youtube/registerGetYouTubeChannelVideoListTool.ts (1 hunks)
  • lib/mcp/tools/youtube/registerGetYouTubeChannelsTool.ts (1 hunks)
  • lib/mcp/tools/youtube/registerGetYouTubeRevenueTool.ts (1 hunks)
  • lib/mcp/tools/youtube/registerSetYouTubeThumbnailTool.ts (1 hunks)
  • lib/supabase/account_api_keys/selectAccountApiKeys.ts (1 hunks)
  • lib/youtube/createYouTubeAnalyticsClient.ts (1 hunks)
  • lib/youtube/fetchYouTubeChannelInfo.ts (1 hunks)
  • lib/youtube/getDefaultDateRange.ts (1 hunks)
  • lib/youtube/getResizedImageBuffer.ts (1 hunks)
  • lib/youtube/getYoutubePlaylistVideos.ts (1 hunks)
  • lib/youtube/handleRevenueError.ts (1 hunks)
  • lib/youtube/oauth-client.ts (1 hunks)
  • lib/youtube/queryAnalyticsReports.ts (1 hunks)
  • package.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sweetmantech
sweetmantech merged commit f8f430e into mainDec 15, 2025
2 of 3 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@sweetmantech