@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 3.21 kB
Source Map (JSON)
{"version":3,"file":"get-settings.mjs","names":["settingServices.getSettings"],"sources":["../../../../../src/libs/http/controllers/settings/get-settings.ts"],"sourcesContent":["import { createFactory } from \"hono/factory\";\nimport { describeRoute } from \"hono-openapi\";\nimport z from \"zod\";\nimport { controllerSchemas } from \"../../../../schemas/settings.js\";\nimport { settingServices } 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 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 getSettingsController = factory.createHandlers(\n\tdescribeRoute({\n\t\tdescription: \"Returns the site settings including meta data.\",\n\t\ttags: [\"settings\"],\n\t\tsummary: \"Get Settings\",\n\t\tresponses: openAPI.responses({\n\t\t\tschema: z.toJSONSchema(controllerSchemas.getSettings.response),\n\t\t}),\n\t\tparameters: openAPI.parameters({\n\t\t\tquery: controllerSchemas.getSettings.query.string,\n\t\t}),\n\t}),\n\tauthenticate(),\n\tvalidate(\"query\", controllerSchemas.getSettings.query.string),\n\tasync (c) => {\n\t\tconst formattedQuery = await buildFormattedQuery(\n\t\t\tc,\n\t\t\tcontrollerSchemas.getSettings.query.formatted,\n\t\t);\n\t\tconst context = createServiceContext(c);\n\n\t\tconst settings = await serviceWrapper(settingServices.getSettings, {\n\t\t\ttransaction: false,\n\t\t\tdefaultError: {\n\t\t\t\ttype: \"basic\",\n\t\t\t\tname: copy(\"server:core.routes.settings.fetch.error.name\"),\n\t\t\t\tmessage: copy(\"server:core.routes.settings.fetch.error.message\"),\n\t\t\t},\n\t\t})(context, {\n\t\t\tincludes: formattedQuery.include,\n\t\t\truntime: c.get(\"runtimeContext\").runtime,\n\t\t\tauthUser: c.get(\"auth\"),\n\t\t});\n\t\tif (settings.error) throw new LucidAPIError(settings.error);\n\n\t\tc.status(200);\n\t\treturn c.json(\n\t\t\tformatAPIResponse(c, {\n\t\t\t\tdata: settings.data,\n\t\t\t}),\n\t\t);\n\t},\n);\n\nexport default getSettingsController;\n"],"mappings":"srBAiBA,MAAM,EAFU,EAEoB,CAAC,CAAC,eACrC,EAAc,CACb,YAAa,iDACb,KAAM,CAAC,UAAU,EACjB,QAAS,eACT,UAAW,EAAQ,UAAU,CAC5B,OAAQ,EAAE,aAAa,EAAkB,YAAY,QAAQ,CAC9D,CAAC,EACD,WAAY,EAAQ,WAAW,CAC9B,MAAO,EAAkB,YAAY,MAAM,MAC5C,CAAC,CACF,CAAC,EACD,EAAa,EACb,EAAS,QAAS,EAAkB,YAAY,MAAM,MAAM,EAC5D,KAAO,IAAM,CACZ,IAAM,EAAiB,MAAM,EAC5B,EACA,EAAkB,YAAY,MAAM,SACrC,EACM,EAAU,EAAqB,CAAC,EAEhC,EAAW,MAAM,EAAeA,EAA6B,CAClE,YAAa,GACb,aAAc,CACb,KAAM,QACN,KAAM,EAAK,8CAA8C,EACzD,QAAS,EAAK,iDAAiD,CAChE,CACD,CAAC,CAAC,CAAC,EAAS,CACX,SAAU,EAAe,QACzB,QAAS,EAAE,IAAI,gBAAgB,CAAC,CAAC,QACjC,SAAU,EAAE,IAAI,MAAM,CACvB,CAAC,EACD,GAAI,EAAS,MAAO,MAAM,IAAI,EAAc,EAAS,KAAK,EAG1D,OADA,EAAE,OAAO,GAAG,EACL,EAAE,KACR,EAAkB,EAAG,CACpB,KAAM,EAAS,IAChB,CAAC,CACF,CACD,CACD"}