Support Lowercase Public Keys in Node API Endpoints

This commit is contained in:
CoryNQ1E
2025-09-10 13:45:05 -07:00
parent cdd66725ec
commit 170bcf394a
2 changed files with 12 additions and 6 deletions
@@ -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
@@ -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) {