18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
// Igneum relay: one function, dispatched on ?fn=. Reached as /api/relay?fn=<fn> with x-relay-token (the Mac tools
|
|
// and the PC clients) or x-igneum-key (the relay key; the intake key for uploads only), and through the rewrite
|
|
// /r/<token>/api/<fn> from the phone's page. The contract and the whole handler live in ../lib/handler.mjs so
|
|
// relay/test/handler.test.mjs drives it with a fake database and fake blobs (5 October 2026, night: X23 to X28).
|
|
import { neon, authed } from '../lib/relay.mjs';
|
|
import { storeBuffer, clientUploadToken, deleteBlobs } from '../lib/blob.mjs';
|
|
import { makeHandler } from '../lib/handler.mjs';
|
|
|
|
const json = (res, status, obj) => { res.status(status).setHeader('Content-Type', 'application/json; charset=utf-8'); res.end(JSON.stringify(obj)); };
|
|
const state = {};
|
|
let inner = null;
|
|
|
|
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 }); }
|
|
if (!inner) inner = makeHandler({ sql, blob: { storeBuffer, clientUploadToken, deleteBlobs }, authed, json, state });
|
|
return inner(req, res);
|
|
}
|