Replace remote with local repo
This commit is contained in:
24
app/api/credits/balance/route.ts
Normal file
24
app/api/credits/balance/route.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* GET /api/credits/balance?handle=<handle>
|
||||
* Returns the VOID credit balance and unlocked tool list for a handle.
|
||||
*/
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { getHandleRecord } from "@/lib/serverLedger";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const handle = searchParams.get("handle")?.trim() ?? "";
|
||||
|
||||
if (!handle) {
|
||||
return NextResponse.json({ ok: false, error: "handle is required" }, { status: 400 });
|
||||
}
|
||||
|
||||
const rec = getHandleRecord(handle);
|
||||
return NextResponse.json({
|
||||
ok: true,
|
||||
handle: handle.toLowerCase(),
|
||||
voidCredits: rec.voidCredits,
|
||||
unlockedToolIds: rec.unlockedTools.map((t) => t.toolId),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user