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.0 KiB
Plaintext
1 line
2.0 KiB
Plaintext
{"version":3,"sources":["../../../src/preferences/requestHandlers/update.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 { update } from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (incomingReq) => {\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 (_err) {\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 doc = await update({\n key: reqWithData.routeParams?.key as string,\n req: reqWithData,\n user: reqWithData?.user,\n value: reqWithData.data?.value || reqWithData.data,\n })\n\n return Response.json(\n {\n doc,\n message: reqWithData.t('general:updatedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","update","updateHandler","incomingReq","data","json","_err","reqWithData","Promise","resolve","doc","key","routeParams","req","user","value","Response","message","t","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,MAAM,QAAQ,0BAAyB;AAEhD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,iHAAiH;IACjH,4FAA4F;IAC5F,IAAIC;IAEJ,IAAI;QACFA,OAAO,MAAMD,YAAYE,IAAI;IAC/B,EAAE,OAAOC,MAAM;QACbF,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,MAAM,MAAMT,OAAO;QACvBU,KAAKJ,YAAYK,WAAW,EAAED;QAC9BE,KAAKN;QACLO,MAAMP,aAAaO;QACnBC,OAAOR,YAAYH,IAAI,EAAEW,SAASR,YAAYH,IAAI;IACpD;IAEA,OAAOY,SAASX,IAAI,CAClB;QACEK;QACAO,SAASV,YAAYW,CAAC,CAAC;IACzB,GACA;QACEnB,QAAQC,WAAWmB,EAAE;IACvB;AAEJ,EAAC"} |