export default defineEventHandler(async (event) => { const xTagHeader = getRequestHeader(event, "x-tag"); if (!xTagHeader || xTagHeader !== "094ut234") { throw createError({ statusCode: 401, statusMessage: "unauthenticated" }); } const query = getQuery(event); const { interestId, linkType } = query; if (!interestId || !linkType) { throw createError({ statusCode: 400, statusMessage: "interestId and linkType are required" }); } const config = getNocoDbConfiguration(); const interestsTableId = "mbs9hjauug4eseo"; // Determine which link field to use let linkFieldId; if (linkType === 'berths') { linkFieldId = "cj7v7bb9pa5eyo3"; // Berths field } else if (linkType === 'recommendations') { linkFieldId = "cgthyq2e95ajc52"; // Berth Recommendations field } else { throw createError({ statusCode: 400, statusMessage: "linkType must be 'berths' or 'recommendations'" }); } const result = await $fetch( `${config.url}/api/v2/tables/${interestsTableId}/links/${linkFieldId}/records/${interestId}`, { headers: { "xc-token": config.token, }, params: { limit: 1000, }, } ); return result; });