Files
FastD 0ac596086a Release wave: no data collection, contact by email, deploy from src/
- Remove the request form, consent checkbox, honeypot, success dialog,
  form.js, analytics.js, the Yandex Metrica id and the cookie banner (D23).
- Contact is a mailto card to harveymonsterteam@gmail.com; privacy.html
  rewritten for "no data collected"; Google Fonts replaced by four
  self-hosted WOFF2 files, so the page makes no third-party request.
- Drop `summary` from the case contract: the project dialog shows the case
  body only, the planet plaque uses tagline, and a project without shots
  opens one honest slot instead of three fake ones.
- Restore the original voice and punctuation in 12 cards, strip internal
  wording from published copy, fix stale counts (20 projects, 5 releases).
- Deploy = contents of src/: api/ moved to archive/api/, new release gate
  scripts/check-release.mjs, deploy guide docs/deploy.md.
- Sync docs: AGENTS.md (D23, D8, R4 closed, structure), design/spec.md
  section 10.31, DESIGN.md, PRODUCT.md, INDEX.md, inventory.
2026-11-15 17:34:40 +03:00

51 lines
2.8 KiB
JavaScript

// Local dev stub for the contact form endpoint.
// Usage: node api/dev-stub.mjs (listens on http://127.0.0.1:8787)
// Point the form's API_URL to http://127.0.0.1:8787/ during development:
// <form id="contact-form" data-endpoint="http://127.0.0.1:8787/api/contact.php" …>
// Same JSON contract as api/contact.php, but logs instead of delivering.
import { createServer } from 'node:http';
const PORT = Number(process.env.PORT) || 8787;
const HOST = '127.0.0.1';
function send(res, status, ok, msg) {
res.writeHead(status, { 'Content-Type': 'application/json; charset=utf-8' });
res.end(JSON.stringify(ok ? { ok: true, message: msg } : { ok: false, error: msg }));
}
createServer((req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
res.setHeader('Access-Control-Allow-Methods', 'POST, OPTIONS');
if (req.method === 'OPTIONS') { res.writeHead(204); return res.end(); }
if (req.method !== 'POST') { return send(res, 405, false, 'Method not allowed.'); }
let raw = '';
req.on('data', (c) => { raw += c; if (raw.length > 64 * 1024) req.destroy(); });
req.on('end', () => {
let body;
try { body = JSON.parse(raw || '{}'); } catch { return send(res, 400, false, 'Expected a JSON body.'); }
const name = String(body.name ?? '').trim();
const contact = String(body.contact ?? '').trim();
const message = String(body.message ?? '').trim();
const consent = body.consent === true;
const meta = body.meta && typeof body.meta === 'object' ? body.meta : {};
if (!consent) return send(res, 422, false, 'Отметьте согласие на обработку персональных данных.');
if (name.length < 2 || name.length > 100) return send(res, 422, false, 'Укажите имя (2–100 символов).');
if (contact.length < 2 || contact.length > 200) return send(res, 422, false, 'Укажите предпочтительное средство связи (2–200 символов).');
if (message.length < 10 || message.length > 4000) return send(res, 422, false, 'Опишите задачу (10–4000 символов).');
console.log('\n=== НОВОЕ СООБЩЕНИЕ (stub) ===');
console.log('Имя: ', name);
console.log('Связь: ', contact);
console.log('Задача: ', message);
if (Object.keys(meta).length) console.log('Мета: ', JSON.stringify(meta));
console.log('================================\n');
send(res, 200, true, 'Сообщение отправлено (stub). Мы ответим в ближайшее время.');
});
}).listen(PORT, HOST, () => {
console.log(`Contact stub: http://${HOST}:${PORT}`);
console.log('POST JSON {name, contact, message, consent, website, meta}');
});