rafmacalaba's picture
feat: human validation, recursive highlighting, data mentions rename
da957b0
import { NextResponse } from 'next/server';
/**
* Returns the HF username for the current token.
* Used to auto-fill the annotator name in production.
*/
export async function GET() {
const token = process.env.HF_TOKEN;
if (!token) {
return NextResponse.json({ username: null }, { status: 200 });
}
try {
const res = await fetch('https://huggingface.co/api/whoami-v2', {
headers: { 'Authorization': `Bearer ${token}` },
});
if (!res.ok) {
return NextResponse.json({ username: null }, { status: 200 });
}
const data = await res.json();
return NextResponse.json({ username: data.name || null });
} catch (error) {
console.error('HF whoami error:', error);
return NextResponse.json({ username: null }, { status: 200 });
}
}