@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 3.37 kB
Source Map (JSON)
{"version":3,"file":"delete-single-permanently.mjs","names":["deleteSinglePermanently","userServices.deleteSinglePermanently"],"sources":["../../../../../src/libs/http/controllers/users/delete-single-permanently.ts"],"sourcesContent":["import { createFactory } from \"hono/factory\";\nimport { describeRoute } from \"hono-openapi\";\nimport { controllerSchemas } from \"../../../../schemas/users.js\";\nimport { userServices } 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 { Permissions } from \"../../../permission/definitions.js\";\nimport authenticate from \"../../middleware/authenticate.js\";\nimport permissions from \"../../middleware/permissions.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 deleteSinglePermanentlyController = factory.createHandlers(\n\tdescribeRoute({\n\t\tdescription:\n\t\t\t\"Permanently delete a single user by ID. The user must be soft-deleted first before it can be permanently deleted.\",\n\t\ttags: [\"users\"],\n\t\tsummary: \"Delete User Permanently\",\n\t\tresponses: openAPI.responses({\n\t\t\tnoProperties: true,\n\t\t}),\n\t\tparameters: openAPI.parameters({\n\t\t\tparams: controllerSchemas.deleteSinglePermanently.params,\n\t\t\theaders: {\n\t\t\t\tcsrf: true,\n\t\t\t},\n\t\t}),\n\t}),\n\tvalidateCSRF,\n\tauthenticate(),\n\tpermissions([Permissions.UsersDelete]),\n\tvalidate(\"param\", controllerSchemas.deleteSinglePermanently.params),\n\tasync (c) => {\n\t\tconst { id } = c.req.valid(\"param\");\n\t\tconst auth = c.get(\"auth\");\n\t\tconst context = createServiceContext(c);\n\n\t\tconst deleteSinglePermanently = await serviceWrapper(\n\t\t\tuserServices.deleteSinglePermanently,\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.user.delete.error.name\"),\n\t\t\t\t\tmessage: copy(\"server:core.routes.user.delete.error.message\"),\n\t\t\t\t},\n\t\t\t},\n\t\t)(context, {\n\t\t\tuserId: Number.parseInt(id, 10),\n\t\t\tcurrentUserId: auth.id,\n\t\t});\n\t\tif (deleteSinglePermanently.error)\n\t\t\tthrow new LucidAPIError(deleteSinglePermanently.error);\n\n\t\tc.status(204);\n\t\treturn c.body(null);\n\t},\n);\n\nexport default deleteSinglePermanentlyController;\n"],"mappings":"2uBAiBA,MAAM,EAFU,EAEgC,CAAC,CAAC,eACjD,EAAc,CACb,YACC,oHACD,KAAM,CAAC,OAAO,EACd,QAAS,0BACT,UAAW,EAAQ,UAAU,CAC5B,aAAc,EACf,CAAC,EACD,WAAY,EAAQ,WAAW,CAC9B,OAAQ,EAAkB,wBAAwB,OAClD,QAAS,CACR,KAAM,EACP,CACD,CAAC,CACF,CAAC,EACD,EACA,EAAa,EACb,EAAY,CAAC,EAAY,WAAW,CAAC,EACrC,EAAS,QAAS,EAAkB,wBAAwB,MAAM,EAClE,KAAO,IAAM,CACZ,GAAM,CAAE,MAAO,EAAE,IAAI,MAAM,OAAO,EAC5B,EAAO,EAAE,IAAI,MAAM,EACnB,EAAU,EAAqB,CAAC,EAEhCA,EAA0B,MAAM,EACrCC,EACA,CACC,YAAa,GACb,aAAc,CACb,KAAM,QACN,KAAM,EAAK,2CAA2C,EACtD,QAAS,EAAK,8CAA8C,CAC7D,CACD,CACD,CAAC,CAAC,EAAS,CACV,OAAQ,OAAO,SAAS,EAAI,EAAE,EAC9B,cAAe,EAAK,EACrB,CAAC,EACD,GAAID,EAAwB,MAC3B,MAAM,IAAI,EAAcA,EAAwB,KAAK,EAGtD,OADA,EAAE,OAAO,GAAG,EACL,EAAE,KAAK,IAAI,CACnB,CACD"}