UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.78 kB
{"version":3,"file":"get-multiple.mjs","names":["optionsFormatter"],"sources":["../../../src/services/options/get-multiple.ts"],"sourcesContent":["import { optionsFormatter } from \"../../libs/formatters/index.js\";\nimport { copy } from \"../../libs/i18n/index.js\";\nimport { OptionsRepository } from \"../../libs/repositories/index.js\";\nimport type { OptionsName } from \"../../schemas/options.js\";\nimport type { Option } from \"../../types/response.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\n\nconst getMultiple: ServiceFn<\n\t[\n\t\t{\n\t\t\tnames: OptionsName[];\n\t\t},\n\t],\n\tOption[]\n> = async (context, data) => {\n\tconst Options = new OptionsRepository(context.db.client, context.config.db);\n\n\tconst optionRes = await Options.selectMultiple({\n\t\tselect: [\"name\", \"value_bool\", \"value_int\", \"value_text\"],\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"name\",\n\t\t\t\toperator: \"in\",\n\t\t\t\tvalue: data.names,\n\t\t\t},\n\t\t],\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t\tdefaultError: {\n\t\t\t\tmessage: copy(\"server:core.options.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t},\n\t});\n\tif (optionRes.error) return optionRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: optionsFormatter.formatMultiple({\n\t\t\toptions: optionRes.data,\n\t\t}),\n\t};\n};\n\nexport default getMultiple;\n"],"mappings":"oJAOA,MAAM,EAOF,MAAO,EAAS,IAAS,CAG5B,IAAM,EAAY,MAAM,IAFJ,EAAkB,EAAQ,GAAG,OAAQ,EAAQ,OAAO,EAE1C,CAAC,CAAC,eAAe,CAC9C,OAAQ,CAAC,OAAQ,aAAc,YAAa,YAAY,EACxD,MAAO,CACN,CACC,IAAK,OACL,SAAU,KACV,MAAO,EAAK,KACb,CACD,EACA,WAAY,CACX,QAAS,GACT,aAAc,CACb,QAAS,EAAK,uCAAuC,EACrD,OAAQ,GACT,CACD,CACD,CAAC,EAGD,OAFI,EAAU,MAAc,EAErB,CACN,MAAO,IAAA,GACP,KAAMA,EAAiB,eAAe,CACrC,QAAS,EAAU,IACpB,CAAC,CACF,CACD"}