Files
tt-booking/app/api/settings/route.ts
T
2025-09-21 17:11:02 +01:00

24 lines
711 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { getSession } from '@/lib/session';
import { db } from '@/lib/db';
import { settings } from '@/lib/db/schema';
export async function GET(request: NextRequest) {
try {
const session = await getSession();
if (!session) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
// Get all settings (users can read settings but not modify them)
const allSettings = await db.select().from(settings);
return NextResponse.json({
settings: allSettings,
});
} catch (error) {
console.error('Error fetching settings:', error);
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
}
}