-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathroute.ts
More file actions
24 lines (21 loc) · 784 Bytes
/
Copy pathroute.ts
File metadata and controls
24 lines (21 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/** GET free-debate grant status for the signed-in user. */
import { NextResponse } from "next/server"
import { auth } from "@/lib/auth"
import { authEnabled } from "@/lib/deploy-config"
import { getFreeDebateStatus } from "@/lib/free-debates"
export async function GET() {
if (!authEnabled()) {
return NextResponse.json({ remaining: 0, active: false, expiresAt: null })
}
const session = await auth()
if (!session?.user?.id) {
return NextResponse.json({ error: "unauthorized" }, { status: 401 })
}
try {
const status = await getFreeDebateStatus(session.user.id)
return NextResponse.json(status)
} catch (error) {
console.error("[free-debate] status failed:", error)
return NextResponse.json({ error: "status_failed" }, { status: 500 })
}
}