()
| 990 | // Public notes (no auth required — used by public page renderer) |
| 991 | if (request.method === "GET" && path === "/public-notes") { |
| 992 | const rows = this.sql.exec( |
| 993 | `SELECT n.id, n.title, n.content, n.published_at, n.created_at, f.name as folder_name |
| 994 | FROM notes n LEFT JOIN folders f ON n.folder_id = f.id |
| 995 | WHERE n.published = 1 AND n.deleted_at IS NULL ORDER BY n.published_at DESC` |
| 996 | ).toArray(); |
| 997 | // Derive the title from content when the stored column is stale — |
| 998 | // the public page and RSS should never show "Untitled" for a note |
| 999 | // that has real text. |
| 1000 | return Response.json(rows.map((row: any) => ({ |
| 1001 | ...row, |
| 1002 | title: (row.title && row.title !== "Untitled") ? row.title : deriveTitleAndPreview(row.content).title || row.title || "Untitled", |
| 1003 | }))); |
| 1004 | } |
| 1005 | |
| 1006 | // --- Media routes --- |
| 1007 | if (request.method === "GET" && path === "/media") { |
no test coverage detected