add blog editor

This commit is contained in:
2026-08-31 16:39:56 +00:00
parent d793400336
commit 4822125787
13 changed files with 447 additions and 60 deletions

View File

@@ -5,7 +5,7 @@ import { sveltekitCookies } from 'better-auth/svelte-kit';
import { getRequestEvent } from '$app/server';
import { db } from '$lib/server/db';
import * as schema from '$lib/server/db/schema';
import type { RequestEvent } from '@sveltejs/kit';
import { error, type RequestEvent } from '@sveltejs/kit';
export const auth = betterAuth({
baseURL: env.ORIGIN ?? 'http://localhost:3000',
@@ -30,9 +30,6 @@ export function isAdmin(event: RequestEvent): boolean {
export function requireAdmin(event: RequestEvent): void {
if (!isAdmin(event)) {
throw new Response(JSON.stringify({ error: 'Unauthorized' }), {
status: 401,
headers: { 'Content-Type': 'application/json' }
});
error(401, { message: 'Unauthorized' });
}
}