Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
2.1 KiB
Plaintext
1 line
2.1 KiB
Plaintext
{"version":3,"sources":["../../../src/preferences/requestHandlers/findOne.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\n\nimport { findOne } from '../operations/findOne.js'\n\nexport const findByIDHandler: PayloadHandler = async (incomingReq): Promise<Response> => {\n // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues\n // However that utility should be used where possible instead of manually appending the data\n let data\n\n try {\n data = await incomingReq.json?.()\n } catch (ignore) {\n data = {}\n }\n\n const reqWithData: PayloadRequest = incomingReq\n\n if (data) {\n reqWithData.data = data\n // @ts-expect-error\n reqWithData.json = () => Promise.resolve(data)\n }\n\n const result = await findOne({\n key: reqWithData.routeParams?.key as string,\n req: reqWithData,\n user: reqWithData.user,\n })\n\n return Response.json(\n {\n ...(result\n ? result\n : {\n message: reqWithData.t('general:notFound'),\n value: null,\n }),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","findOne","findByIDHandler","incomingReq","data","json","ignore","reqWithData","Promise","resolve","result","key","routeParams","req","user","Response","message","t","value","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,OAAO,QAAQ,2BAA0B;AAElD,OAAO,MAAMC,kBAAkC,OAAOC;IACpD,iHAAiH;IACjH,4FAA4F;IAC5F,IAAIC;IAEJ,IAAI;QACFA,OAAO,MAAMD,YAAYE,IAAI;IAC/B,EAAE,OAAOC,QAAQ;QACfF,OAAO,CAAC;IACV;IAEA,MAAMG,cAA8BJ;IAEpC,IAAIC,MAAM;QACRG,YAAYH,IAAI,GAAGA;QACnB,mBAAmB;QACnBG,YAAYF,IAAI,GAAG,IAAMG,QAAQC,OAAO,CAACL;IAC3C;IAEA,MAAMM,SAAS,MAAMT,QAAQ;QAC3BU,KAAKJ,YAAYK,WAAW,EAAED;QAC9BE,KAAKN;QACLO,MAAMP,YAAYO,IAAI;IACxB;IAEA,OAAOC,SAASV,IAAI,CAClB;QACE,GAAIK,SACAA,SACA;YACEM,SAAST,YAAYU,CAAC,CAAC;YACvBC,OAAO;QACT,CAAC;IACP,GACA;QACEnB,QAAQC,WAAWmB,EAAE;IACvB;AAEJ,EAAC"} |