@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 3.82 kB
Source Map (JSON)
{"version":3,"file":"update-profile-picture.mjs","names":["updateProfilePicture","accountServices.updateProfilePicture"],"sources":["../../../../../src/libs/http/controllers/account/update-profile-picture.ts"],"sourcesContent":["import { createFactory } from \"hono/factory\";\nimport { describeRoute } from \"hono-openapi\";\nimport { controllerSchemas } from \"../../../../schemas/account.js\";\nimport { accountServices } from \"../../../../services/index.js\";\nimport { LucidAPIError } from \"../../../../utils/errors/index.js\";\nimport serviceWrapper from \"../../../../utils/services/service-wrapper.js\";\nimport { copy } from \"../../../i18n/index.js\";\nimport authenticate from \"../../middleware/authenticate.js\";\nimport validate from \"../../middleware/validate.js\";\nimport validateCSRF from \"../../middleware/validate-csrf.js\";\nimport openAPI from \"../../openapi/index.js\";\nimport createServiceContext from \"../../utils/create-service-context.js\";\n\nconst factory = createFactory();\n\nconst updateProfilePictureController = factory.createHandlers(\n\tdescribeRoute({\n\t\tdescription: \"Update the authenticated user's profile picture.\",\n\t\ttags: [\"account\"],\n\t\tsummary: \"Update Profile Picture\",\n\t\tresponses: openAPI.responses(),\n\t\tparameters: openAPI.parameters({\n\t\t\theaders: {\n\t\t\t\tcsrf: true,\n\t\t\t},\n\t\t}),\n\t\trequestBody: openAPI.requestBody(\n\t\t\tcontrollerSchemas.updateProfilePicture.body,\n\t\t),\n\t}),\n\tvalidateCSRF,\n\tauthenticate(),\n\tvalidate(\"json\", controllerSchemas.updateProfilePicture.body),\n\tasync (c) => {\n\t\tconst body = c.req.valid(\"json\");\n\t\tconst context = createServiceContext(c);\n\n\t\tconst updateProfilePicture = await serviceWrapper(\n\t\t\taccountServices.updateProfilePicture,\n\t\t\t{\n\t\t\t\ttransaction: true,\n\t\t\t\tdefaultError: {\n\t\t\t\t\ttype: \"basic\",\n\t\t\t\t\tname: copy(\"server:core.routes.profile.picture.update.error.name\"),\n\t\t\t\t\tmessage: copy(\n\t\t\t\t\t\t\"server:core.routes.profile.picture.update.error.message\",\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t)(context, {\n\t\t\ttargetUserId: c.get(\"auth\").id,\n\t\t\tactorUserId: c.get(\"auth\").id,\n\t\t\tallowSelf: true,\n\t\t\tkey: body.key,\n\t\t\tfileName: body.fileName,\n\t\t\twidth: body.width,\n\t\t\theight: body.height,\n\t\t\tfocalPoint: body.focalPoint,\n\t\t\tblurHash: body.blurHash,\n\t\t\taverageColor: body.averageColor,\n\t\t\tbase64: body.base64,\n\t\t\tisDark: body.isDark,\n\t\t\tisLight: body.isLight,\n\t\t\torigin: body.origin,\n\t\t\taiGenerationRequestId: body.aiGenerationRequestId,\n\t\t\ttitle: body.title,\n\t\t\talt: body.alt,\n\t\t\tcrop: body.crop,\n\t\t});\n\t\tif (updateProfilePicture.error) {\n\t\t\tthrow new LucidAPIError(updateProfilePicture.error);\n\t\t}\n\n\t\tc.status(204);\n\t\treturn c.body(null);\n\t},\n);\n\nexport default updateProfilePictureController;\n"],"mappings":"0nBAeA,MAAM,EAFU,EAE6B,CAAC,CAAC,eAC9C,EAAc,CACb,YAAa,mDACb,KAAM,CAAC,SAAS,EAChB,QAAS,yBACT,UAAW,EAAQ,UAAU,EAC7B,WAAY,EAAQ,WAAW,CAC9B,QAAS,CACR,KAAM,EACP,CACD,CAAC,EACD,YAAa,EAAQ,YACpB,EAAkB,qBAAqB,IACxC,CACD,CAAC,EACD,EACA,EAAa,EACb,EAAS,OAAQ,EAAkB,qBAAqB,IAAI,EAC5D,KAAO,IAAM,CACZ,IAAM,EAAO,EAAE,IAAI,MAAM,MAAM,EACzB,EAAU,EAAqB,CAAC,EAEhCA,EAAuB,MAAM,EAClCC,EACA,CACC,YAAa,GACb,aAAc,CACb,KAAM,QACN,KAAM,EAAK,sDAAsD,EACjE,QAAS,EACR,yDACD,CACD,CACD,CACD,CAAC,CAAC,EAAS,CACV,aAAc,EAAE,IAAI,MAAM,CAAC,CAAC,GAC5B,YAAa,EAAE,IAAI,MAAM,CAAC,CAAC,GAC3B,UAAW,GACX,IAAK,EAAK,IACV,SAAU,EAAK,SACf,MAAO,EAAK,MACZ,OAAQ,EAAK,OACb,WAAY,EAAK,WACjB,SAAU,EAAK,SACf,aAAc,EAAK,aACnB,OAAQ,EAAK,OACb,OAAQ,EAAK,OACb,QAAS,EAAK,QACd,OAAQ,EAAK,OACb,sBAAuB,EAAK,sBAC5B,MAAO,EAAK,MACZ,IAAK,EAAK,IACV,KAAM,EAAK,IACZ,CAAC,EACD,GAAID,EAAqB,MACxB,MAAM,IAAI,EAAcA,EAAqB,KAAK,EAInD,OADA,EAAE,OAAO,GAAG,EACL,EAAE,KAAK,IAAI,CACnB,CACD"}