feat: rediseño UI completo + infra email + stats

This commit is contained in:
hacklab 2026-04-20 00:46:00 +02:00
parent 93d75ddafe
commit 24401c0ee5
37 changed files with 2162 additions and 412 deletions

View file

@ -94,7 +94,9 @@ async function searchGoogle(query) {
const err = await res.json().catch(() => ({}));
throw new Error(err.error?.message || `HTTP ${res.status}`);
}
const data = await res.json();
const text = await res.text();
if (text.length > 500_000) throw new Error('Respuesta Google CSE demasiado grande');
const data = JSON.parse(text);
return (data.items || []).map(item => ({
title: String(item.title || '').slice(0, 300),
url: String(item.link || ''),
@ -103,6 +105,8 @@ async function searchGoogle(query) {
}));
}
const stats = require('../services/stats');
/* ── Handler principal ──────────────────────────────────────── */
module.exports = async (req, res) => {
const raw = req.query.q;
@ -150,5 +154,6 @@ module.exports = async (req, res) => {
engine: r.engine,
}));
stats.record({ type: 'search' });
res.json({ results, query, total: raw_results.length });
};