Replace remote with local repo
This commit is contained in:
25
app/api/admin/credit/route.ts
Normal file
25
app/api/admin/credit/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* POST /api/admin/credit { handle, amount }
|
||||
* Manually adds VOID credits to a handle (operator use only).
|
||||
*/
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { adminCreditVoid } from "@/lib/serverLedger";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
let body: unknown;
|
||||
try { body = await req.json(); } catch {
|
||||
return NextResponse.json({ ok: false, error: "Invalid JSON" }, { status: 400 });
|
||||
}
|
||||
|
||||
const { handle, amount } = (body as Record<string, unknown>) ?? {};
|
||||
if (typeof handle !== "string" || !handle.trim())
|
||||
return NextResponse.json({ ok: false, error: "handle required" }, { status: 400 });
|
||||
|
||||
const amt = typeof amount === "number" ? Math.floor(amount) : 0;
|
||||
if (amt <= 0)
|
||||
return NextResponse.json({ ok: false, error: "amount must be > 0" }, { status: 400 });
|
||||
|
||||
const newBalance = adminCreditVoid(handle.trim(), amt);
|
||||
return NextResponse.json({ ok: true, handle: handle.trim().toLowerCase(), newBalance });
|
||||
}
|
||||
13
app/api/admin/ledger/route.ts
Normal file
13
app/api/admin/ledger/route.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* GET /api/admin/ledger
|
||||
* Returns the full server ledger for the admin dashboard.
|
||||
* Protected: only the drjones session can call this.
|
||||
*/
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { readLedger } from "@/lib/serverLedger";
|
||||
|
||||
export async function GET() {
|
||||
const ledger = readLedger();
|
||||
return NextResponse.json({ ok: true, handles: ledger.handles, invoiceIndex: ledger.invoiceIndex });
|
||||
}
|
||||
12
app/api/admin/raffle/route.ts
Normal file
12
app/api/admin/raffle/route.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* GET /api/admin/raffle
|
||||
* Returns full raffle entry list for the admin dashboard.
|
||||
*/
|
||||
|
||||
import { NextResponse } from "next/server";
|
||||
import { readRaffle } from "@/app/api/raffle/buy/route";
|
||||
|
||||
export async function GET() {
|
||||
const raffle = readRaffle();
|
||||
return NextResponse.json({ ok: true, entries: raffle.entries, drawAt: raffle.drawAt });
|
||||
}
|
||||
Reference in New Issue
Block a user