zeno

Express.js Integration

const express = require('express');
const app = express();

const ZENO_VERIFY_URL = '[https://zeno.secops.workers.dev/api/verify](https://zeno.secops.workers.dev/api/verify)';

const zenoMiddleware = async (req, res, next) => {
    const token = req.body['zeno-token']; // Or header
    
    if (!token) return res.status(400).json({ error: 'Missing captcha token' });

    try {
        const response = await fetch(ZENO_VERIFY_URL, {
            method: 'POST',
            headers: { 'Content-Type': 'application/json' },
            body: JSON.stringify({ 
                token,
                site_key: 'YOUR_SITE_KEY' // Ensure you pass your site key
            })
        });
        
        const data = await response.json();
        
        if (data.valid) {
            next();
        } else {
            res.status(403).json({ error: 'Captcha verification failed' });
        }
    } catch (err) {
        res.status(500).json({ error: 'Server error during verification' });
    }
};

app.post('/login', zenoMiddleware, (req, res) => {
    res.json({ success: true });
});