remove admin routes until TinyAuth is set up

This commit is contained in:
Lewis Wynne 2026-04-05 01:21:24 +01:00
parent 8a9c56c3d5
commit c0d1feaacd
3 changed files with 1 additions and 72 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ dist
data
pnpm-lock.yaml
**/.env
CLAUDE.md

View file

@ -1,51 +0,0 @@
---
export const prerender = false;
import { getPendingEntries, type GuestbookEntry } from '../lib/db';
import Layout from '../layouts/Layout.astro';
import { formatDate } from '../lib/format';
let entries: GuestbookEntry[] = [];
try {
entries = await getPendingEntries();
} catch {
// handle error
}
---
<Layout title="admin - guestbook" showHeader={false}>
<h1>guestbook admin</h1>
{entries.length === 0 ? (
<p class="muted">no pending entries</p>
) : (
<ul id="entries">
{entries.map(e => (
<li data-id={e.id}>
<span class="muted">{formatDate(e.createdAt)}</span>
<strong>{e.name}</strong>
{e.url && <a href={e.url}>{e.url}</a>}
<p>{e.message}</p>
<button class="approve">approve</button>
<button class="reject">reject</button>
</li>
))}
</ul>
)}
<script>
document.querySelectorAll('#entries li').forEach(li => {
const id = li.getAttribute('data-id');
li.querySelector('.approve')?.addEventListener('click', async () => {
const res = await fetch(`/api/guestbook/${id}`, { method: 'PATCH' });
if (res.ok) li.remove();
});
li.querySelector('.reject')?.addEventListener('click', async () => {
const res = await fetch(`/api/guestbook/${id}`, { method: 'DELETE' });
if (res.ok) li.remove();
});
});
</script>
</Layout>

View file

@ -1,21 +0,0 @@
import type { APIRoute } from 'astro';
import { approveEntry, deleteEntry } from '../../../lib/db';
import { jsonResponse, errorResponse } from '../../../lib/api';
export const prerender = false;
export const PATCH: APIRoute = async ({ params }) => {
const id = parseInt(params.id!, 10);
if (isNaN(id)) return errorResponse('Invalid ID', 400);
await approveEntry(id);
return jsonResponse({ success: true });
};
export const DELETE: APIRoute = async ({ params }) => {
const id = parseInt(params.id!, 10);
if (isNaN(id)) return errorResponse('Invalid ID', 400);
await deleteEntry(id);
return jsonResponse({ success: true });
};