Skip to content

Commit e7e3e2a

Browse files
committed
create api webhook handler to revalidate 10y page
1 parent 9bec884 commit e7e3e2a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

app/api/torch-webhook/route.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { revalidatePath } from "next/cache"
2+
import { NextRequest, NextResponse } from "next/server"
3+
4+
export async function POST(req: NextRequest) {
5+
const body = await req.json()
6+
7+
console.log("Torch webhook", body)
8+
9+
const webhookId = body.webhookId
10+
11+
if (webhookId !== Number(process.env.TORCH_WEBHOOK_ID)) {
12+
return NextResponse.json({ message: "Invalid webhook ID" }, { status: 401 })
13+
}
14+
15+
// revalidate the 10 years page
16+
revalidatePath("/10years")
17+
console.log("Revalidated 10 years page")
18+
19+
return NextResponse.json({ message: "OK" })
20+
}

0 commit comments

Comments
 (0)