export default defineEventHandler(async (event) => {
  const xTagHeader = getRequestHeader(event, "x-tag");
  console.log('[get-interests] Request received with x-tag:', xTagHeader);

  if (!xTagHeader || (xTagHeader !== "094ut234" && xTagHeader !== "pjnvü1230")) {
    console.error('[get-interests] Authentication failed - invalid x-tag:', xTagHeader);
    throw createError({ statusCode: 401, statusMessage: "unauthenticated" });
  }

  try {
    console.log('[get-interests] Fetching interests...');
    const interests = await getInterests();
    console.log('[get-interests] Successfully fetched interests, count:', interests.list?.length || 0);
    return interests;
  } catch (error) {
    console.error('[get-interests] Error occurred:', error);
    console.error('[get-interests] Error details:', error instanceof Error ? error.message : 'Unknown error');
    throw error;
  }
});
