import express from 'express';
import { createClient } from '@private-captcha/private-captcha-js';
const app = express();
app.use(express.urlencoded({ extended: false }));
const client = createClient({ apiKey: 'YOUR_API_KEY' });
app.post('/submit', async (req, res) => {
try {
const result = await client.verifyRequest(req, 'YOUR_SITEKEY');
if (!result.ok()) {
return res.status(403).send('Captcha verification failed');
}
} catch (error) {
return res.status(403).send('Captcha verification failed');
}
// Verification passed. Process your form submission here.
res.send('Success!');
});