From 170bcf394aa83909997d6479ef04037d6746594e Mon Sep 17 00:00:00 2001 From: CoryNQ1E Date: Wed, 10 Sep 2025 13:45:05 -0700 Subject: [PATCH] Support Lowercase Public Keys in Node API Endpoints --- src/app/api/meshcore/node/[publicKey]/neighbors/route.ts | 9 ++++++--- src/app/api/meshcore/node/[publicKey]/route.ts | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/api/meshcore/node/[publicKey]/neighbors/route.ts b/src/app/api/meshcore/node/[publicKey]/neighbors/route.ts index fb86553..6f1a4bb 100644 --- a/src/app/api/meshcore/node/[publicKey]/neighbors/route.ts +++ b/src/app/api/meshcore/node/[publicKey]/neighbors/route.ts @@ -6,11 +6,11 @@ export async function GET( { params }: { params: Promise<{ publicKey: string }> } ) { try { - const { publicKey } = await params; + const { publicKey: rawPublicKey } = await params; const { searchParams } = new URL(req.url); const lastSeen = searchParams.get("lastSeen"); - if (!publicKey) { + if (!rawPublicKey) { return NextResponse.json({ error: "Public key is required", code: "MISSING_PUBLIC_KEY" @@ -18,13 +18,16 @@ export async function GET( } // Validate public key format (basic validation) - if (publicKey.length < 10) { + if (rawPublicKey.length < 10) { return NextResponse.json({ error: "Invalid public key format", code: "INVALID_PUBLIC_KEY" }, { status: 400 }); } + // Normalize public key to uppercase for database query + const publicKey = rawPublicKey.toUpperCase(); + const neighbors = await getMeshcoreNodeNeighbors(publicKey, lastSeen); // Check if the parent node exists by trying to get basic node info diff --git a/src/app/api/meshcore/node/[publicKey]/route.ts b/src/app/api/meshcore/node/[publicKey]/route.ts index 4904478..a4ad122 100644 --- a/src/app/api/meshcore/node/[publicKey]/route.ts +++ b/src/app/api/meshcore/node/[publicKey]/route.ts @@ -6,11 +6,11 @@ export async function GET( { params }: { params: Promise<{ publicKey: string }> } ) { try { - const { publicKey } = await params; + const { publicKey: rawPublicKey } = await params; const { searchParams } = new URL(req.url); const limit = parseInt(searchParams.get("limit") || "50", 10); - if (!publicKey) { + if (!rawPublicKey) { return NextResponse.json({ error: "Public key is required", code: "MISSING_PUBLIC_KEY" @@ -18,13 +18,16 @@ export async function GET( } // Validate public key format (basic validation) - if (publicKey.length < 10) { + if (rawPublicKey.length < 10) { return NextResponse.json({ error: "Invalid public key format", code: "INVALID_PUBLIC_KEY" }, { status: 400 }); } + // Normalize public key to uppercase for database query + const publicKey = rawPublicKey.toUpperCase(); + const nodeInfo = await getMeshcoreNodeInfo(publicKey, limit); if (!nodeInfo) {