// Igneum wake: the apps' long-poll for a new jobs file (app/igneum-app/src/jobrun.rs, 0.3.6). Reached at /wake // (public: the apps hold no token) and at /r//wake (the same function; the token matters only to POST). // The contract and the whole handler live in ../lib/wake.mjs so the test can drive it without a database. // GET wake?since=[&hold=45] up to 45 s; {stamp, at, added, changed, held_ms}; 30 a minute per IP // POST wake {stamp, added?} the relay's auth (token in the path or x-relay-token, or the relay key in x-igneum-key; // the intake key opens nothing here, X23) // maxDuration 60 s for this file is set in vercel.json. import { neon, authedNoIntake as authed, readJson } from '../lib/relay.mjs'; import { makeHandler, RateLimit } from '../lib/wake.mjs'; const json = (res, status, obj) => { res.status(status).setHeader('Content-Type', 'application/json; charset=utf-8'); res.end(JSON.stringify(obj)); }; const limiter = new RateLimit(); const holds = { n: 0 }; export default async function handler(req, res) { let sql; try { sql = neon(); } catch (e) { res.setHeader('Cache-Control', 'no-store'); return json(res, 500, { ok: false, error: e.message }); } return makeHandler({ sql, authed, readJson, json, limiter, holds })(req, res); }