-
Notifications
You must be signed in to change notification settings - Fork 1
fix: v1 API audit - stealth support, enriched responses, new endpoints, doc corrections #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0e9d34f
39db41c
ceae3f6
1ee3ca5
61b2c8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { NextRequest, NextResponse } from 'next/server' | ||
| import { createServerClient } from '@/lib/supabase' | ||
| import { verifyApiKey } from '@/lib/api/verify-api-key' | ||
| import { getChains } from '@/lib/api/get-chains' | ||
|
|
||
| /** | ||
| * GET /api/v1/chains?type=all|evm|solana&hasUSDC=true | ||
| */ | ||
| export async function GET(req: NextRequest) { | ||
| const { error } = await verifyApiKey(req) | ||
|
|
||
| if (error) { | ||
| return NextResponse.json({ error }, { status: 401 }) | ||
| } | ||
|
|
||
| try { | ||
| const { searchParams } = new URL(req.url) | ||
| const rawType = searchParams.get('type') || 'all' | ||
| const type = ['all', 'evm', 'solana', 'bitcoin', 'near', 'tron', 'sui', 'ton', 'starknet', 'aptos'].includes(rawType) ? rawType : 'all' | ||
| const hasUSDC = searchParams.get('hasUSDC') === 'true' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Flash Review 🧹 Code Quality: Using Fix: Consider importing the correct Supabase client type (e.g., |
||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| const supabase = createServerClient() as any | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Flash Review 🧹 Code Quality: Using Fix: Ensure |
||
| const result = await getChains(supabase, { type, hasUSDC }) | ||
|
|
||
| return NextResponse.json({ | ||
| data: result.chains, | ||
| total: result.total, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Flash Review 🧹 Code Quality: Fix: Integrate a dedicated logger (e.g., Pino, Winston, or a custom wrapper around a service like Sentry) to handle errors consistently across the application. |
||
| }) | ||
| } catch (err) { | ||
| console.error('V1 Chains Error:', err) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Flash Review 🧹 Code Quality: Fix: Replace |
||
| return NextResponse.json({ error: 'Failed to fetch chains' }, { status: 500 }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡ Flash Review
🚨 Security: The
typequery parameter is taken directly from user input without validation against allowed values. IfgetChainsuses this parameter directly in a SQL query, it could be vulnerable to SQL injection.Fix: Implement Zod validation for
typeto ensure it's one of the expected enum values ('all','evm','solana').