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.83 kB
{"version":3,"file":"delete-single.mjs","names":[],"sources":["../../../src/services/email/delete-single.ts"],"sourcesContent":["import { copy } from \"../../libs/i18n/index.js\";\nimport { EmailsRepository } from \"../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../utils/services/types.js\";\n\nconst deleteSingle: ServiceFn<\n\t[\n\t\t{\n\t\t\tid: number;\n\t\t},\n\t],\n\tundefined\n> = async (context, data) => {\n\tconst Emails = new EmailsRepository(context.db.client, context.config.db);\n\n\tconst emailRes = await Emails.selectSingleById({\n\t\tid: data.id,\n\t\ttenantKey: context.request.tenantKey,\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t\tdefaultError: {\n\t\t\t\tmessage: copy(\"server:core.email.not.found.message\"),\n\t\t\t\tstatus: 404,\n\t\t\t},\n\t\t},\n\t});\n\tif (emailRes.error) return emailRes;\n\n\tconst deleteEmailRes = await Emails.deleteSingle({\n\t\treturning: [\"id\"],\n\t\twhere: [\n\t\t\t{\n\t\t\t\tkey: \"id\",\n\t\t\t\toperator: \"=\",\n\t\t\t\tvalue: data.id,\n\t\t\t},\n\t\t],\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t\tdefaultError: {\n\t\t\t\tstatus: 500,\n\t\t\t},\n\t\t},\n\t});\n\tif (deleteEmailRes.error) return deleteEmailRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default deleteSingle;\n"],"mappings":"kGAIA,MAAM,EAOF,MAAO,EAAS,IAAS,CAC5B,IAAM,EAAS,IAAI,EAAiB,EAAQ,GAAG,OAAQ,EAAQ,OAAO,EAAE,EAElE,EAAW,MAAM,EAAO,iBAAiB,CAC9C,GAAI,EAAK,GACT,UAAW,EAAQ,QAAQ,UAC3B,WAAY,CACX,QAAS,GACT,aAAc,CACb,QAAS,EAAK,qCAAqC,EACnD,OAAQ,GACT,CACD,CACD,CAAC,EACD,GAAI,EAAS,MAAO,OAAO,EAE3B,IAAM,EAAiB,MAAM,EAAO,aAAa,CAChD,UAAW,CAAC,IAAI,EAChB,MAAO,CACN,CACC,IAAK,KACL,SAAU,IACV,MAAO,EAAK,EACb,CACD,EACA,WAAY,CACX,QAAS,GACT,aAAc,CACb,OAAQ,GACT,CACD,CACD,CAAC,EAGD,OAFI,EAAe,MAAc,EAE1B,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}