fix editor

This commit is contained in:
Your Name 2026-08-22 11:29:04 -04:00
parent 3a7031e462
commit f6bde50ce3
6 changed files with 305 additions and 50 deletions

View file

@ -1,7 +1,13 @@
function handler(req, res) {
const sql = require("db")("bliss").sql;
const kind = "template";
const artifact = sql.prepare("SELECT * FROM templates WHERE id = ?").get(req.params.id);
if (!artifact) return res.status(404).send("Template not found");
res.render("inspector/artifact_editor", { kind, artifact });
// Read a template's source through the plumbing API rather than mounting the
// prime db directly (see route-editor.js for the why). Forwarding the caller's
// session cookie keeps the read owner-checked: plumbing 404s any template in a
// structure the user can't see.
async function handler(req, res) {
const base = `${req.protocol}://${req.get("host")}`;
const response = await fetch(`${base}/plumbing/templates/${req.params.id}`, {
headers: { cookie: req.headers.cookie || "" },
});
if (!response.ok) return res.status(response.status).send("Template not found");
const artifact = await response.json();
res.render("inspector/artifact_editor", { kind: "template", artifact });
}