2025-06-17 16:07:15 +02:00
|
|
|
import { getBerths } from "../utils/nocodb";
|
2025-06-15 16:18:29 +02:00
|
|
|
import { requireAuth } from "../utils/auth";
|
|
|
|
|
|
2025-06-03 17:57:08 +02:00
|
|
|
export default defineEventHandler(async (event) => {
|
2025-06-15 16:18:29 +02:00
|
|
|
console.log('[get-berths] Request received');
|
2025-06-03 17:57:08 +02:00
|
|
|
|
2025-06-15 16:18:29 +02:00
|
|
|
// Check authentication (x-tag header OR Keycloak session)
|
|
|
|
|
await requireAuth(event);
|
2025-06-03 17:57:08 +02:00
|
|
|
|
2025-06-09 23:33:20 +02:00
|
|
|
try {
|
|
|
|
|
console.log('[get-berths] Fetching berths...');
|
2025-06-17 16:07:15 +02:00
|
|
|
const berths = await getBerths();
|
2025-06-09 23:33:20 +02:00
|
|
|
console.log('[get-berths] Successfully fetched berths, count:', berths.list?.length || 0);
|
|
|
|
|
return berths;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('[get-berths] Error occurred:', error);
|
|
|
|
|
console.error('[get-berths] Error details:', error instanceof Error ? error.message : 'Unknown error');
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
2025-06-03 17:57:08 +02:00
|
|
|
});
|