@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 3.61 kB
Source Map (JSON)
{"version":3,"file":"get-all.mjs","names":["clientIntegrationServices.getAll"],"sources":["../../../../../src/libs/http/controllers/client-integrations/get-all.ts"],"sourcesContent":["import { createFactory } from \"hono/factory\";\nimport { describeRoute } from \"hono-openapi\";\nimport z from \"zod\";\nimport { controllerSchemas } from \"../../../../schemas/client-integrations.js\";\nimport { clientIntegrationServices } 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 openAPI from \"../../openapi/index.js\";\nimport buildFormattedQuery from \"../../utils/build-formatted-query.js\";\nimport formatAPIResponse from \"../../utils/build-response.js\";\nimport createServiceContext from \"../../utils/create-service-context.js\";\n\nconst factory = createFactory();\n\nconst getAllController = factory.createHandlers(\n\tdescribeRoute({\n\t\tdescription: \"Returns client integrations based on the query parameters.\",\n\t\ttags: [\"client-integrations\"],\n\t\tsummary: \"Get All Client Integrations\",\n\t\tresponses: openAPI.responses({\n\t\t\tschema: z.toJSONSchema(controllerSchemas.getAll.response),\n\t\t\tpaginated: true,\n\t\t}),\n\t\tparameters: openAPI.parameters({\n\t\t\tquery: controllerSchemas.getAll.query.string,\n\t\t}),\n\t}),\n\tauthenticate(),\n\tpermissions([Permissions.IntegrationRead]),\n\tvalidate(\"query\", controllerSchemas.getAll.query.string),\n\tasync (c) => {\n\t\tconst formattedQuery = await buildFormattedQuery(\n\t\t\tc,\n\t\t\tcontrollerSchemas.getAll.query.formatted,\n\t\t);\n\t\tconst context = createServiceContext(c);\n\t\tconst getAllRes = await serviceWrapper(clientIntegrationServices.getAll, {\n\t\t\ttransaction: false,\n\t\t\tdefaultError: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tname: copy(\"server:core.routes.client.integrations.fetch.error.name\"),\n\t\t\t\tmessage: copy(\n\t\t\t\t\t\"server:core.routes.client.integrations.fetch.error.message\",\n\t\t\t\t),\n\t\t\t},\n\t\t})(context, {\n\t\t\tquery: formattedQuery,\n\t\t});\n\t\tif (getAllRes.error) throw new LucidAPIError(getAllRes.error);\n\n\t\tc.status(200);\n\t\treturn c.json(\n\t\t\tformatAPIResponse(c, {\n\t\t\t\tdata: getAllRes.data.data,\n\t\t\t\tpagination: {\n\t\t\t\t\tcount: getAllRes.data.count,\n\t\t\t\t\tpage: formattedQuery.page,\n\t\t\t\t\tperPage: formattedQuery.perPage,\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\t},\n);\n\nexport default getAllController;\n"],"mappings":"yzBAmBA,MAAM,EAFU,EAEe,CAAC,CAAC,eAChC,EAAc,CACb,YAAa,6DACb,KAAM,CAAC,qBAAqB,EAC5B,QAAS,8BACT,UAAW,EAAQ,UAAU,CAC5B,OAAQ,EAAE,aAAa,EAAkB,OAAO,QAAQ,EACxD,UAAW,EACZ,CAAC,EACD,WAAY,EAAQ,WAAW,CAC9B,MAAO,EAAkB,OAAO,MAAM,MACvC,CAAC,CACF,CAAC,EACD,EAAa,EACb,EAAY,CAAC,EAAY,eAAe,CAAC,EACzC,EAAS,QAAS,EAAkB,OAAO,MAAM,MAAM,EACvD,KAAO,IAAM,CACZ,IAAM,EAAiB,MAAM,EAC5B,EACA,EAAkB,OAAO,MAAM,SAChC,EACM,EAAU,EAAqB,CAAC,EAChC,EAAY,MAAM,EAAeA,EAAkC,CACxE,YAAa,GACb,aAAc,CACb,KAAM,QACN,KAAM,EAAK,yDAAyD,EACpE,QAAS,EACR,4DACD,CACD,CACD,CAAC,CAAC,CAAC,EAAS,CACX,MAAO,CACR,CAAC,EACD,GAAI,EAAU,MAAO,MAAM,IAAI,EAAc,EAAU,KAAK,EAG5D,OADA,EAAE,OAAO,GAAG,EACL,EAAE,KACR,EAAkB,EAAG,CACpB,KAAM,EAAU,KAAK,KACrB,WAAY,CACX,MAAO,EAAU,KAAK,MACtB,KAAM,EAAe,KACrB,QAAS,EAAe,OACzB,CACD,CAAC,CACF,CACD,CACD"}