create helpdesk tickets from form submission (#111)

This commit is contained in:
Will Freeman
2026-04-21 11:36:24 -06:00
committed by GitHub
parent deafac1a9e
commit c298a3f5d4
4 changed files with 137 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
const TURNSTILE_SECRET_KEY = process.env.TURNSTILE_SECRET_KEY || '';
const SITEVERIFY_URL = 'https://challenges.cloudflare.com/turnstile/v0/siteverify';
export class TurnstileClient {
async verify(token: string, remoteIp?: string): Promise<boolean> {
const body = new URLSearchParams({
secret: TURNSTILE_SECRET_KEY,
response: token,
...(remoteIp ? { remoteip: remoteIp } : {}),
});
const response = await fetch(SITEVERIFY_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: body.toString(),
});
if (!response.ok) {
throw new Error(`Turnstile siteverify request failed: ${response.status}`);
}
const json = await response.json() as { success: boolean };
return json.success === true;
}
}