function parseJSON(str, fallback) { try { return JSON.parse(str ?? '{}'); } catch (e) { console.error('Error parsing JSON:', e); return fallback; } } export default function (route, param, inFilter = true) { const params = parseJSON(route?.query?.params ?? route, {}); let where = null; if (!inFilter) { where = params; } else { const { filter: filterStr = '{}' } = params; where = parseJSON(filterStr, {})?.where; } if (where && where[param] !== undefined) { return where[param]; } return null; }