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.63 kB
{"version":3,"file":"get-adapter.mjs","names":["constants"],"sources":["../../../src/libs/email/get-adapter.ts"],"sourcesContent":["import constants from \"../../constants/constants.js\";\nimport type { Config } from \"../../types/config.js\";\nimport logger from \"../logger/index.js\";\nimport passthroughEmailAdapter from \"./adapters/passthrough.js\";\nimport type { EmailAdapterInstance } from \"./types.js\";\n\n/**\n * Get the preferred email adapter. Falls back to passthrough adapter.\n */\nconst getEmailAdapter = async (\n\tconfig: Config,\n): Promise<EmailAdapterInstance> => {\n\ttry {\n\t\tif (config.email?.adapter) {\n\t\t\tconst adapter =\n\t\t\t\ttypeof config.email.adapter === \"function\"\n\t\t\t\t\t? await config.email.adapter()\n\t\t\t\t\t: config.email.adapter;\n\n\t\t\treturn await adapter;\n\t\t}\n\n\t\treturn await passthroughEmailAdapter();\n\t} catch (error) {\n\t\tlogger.error({\n\t\t\terror,\n\t\t\tevent: \"email-adapter.initialization.failed\",\n\t\t\tscope: constants.logScopes.emailAdapter,\n\t\t\tmessage: \"Failed to initialize email adapter\",\n\t\t\tdata: {\n\t\t\t\terrorMessage: error instanceof Error ? error.message : String(error),\n\t\t\t},\n\t\t});\n\n\t\treturn await passthroughEmailAdapter();\n\t}\n};\n\nexport default getEmailAdapter;\n"],"mappings":"0HASA,MAAM,EAAkB,KACvB,IACmC,CACnC,GAAI,CAUH,OATI,EAAO,OAAO,QAMV,MAJN,OAAO,EAAO,MAAM,SAAY,WAC7B,MAAM,EAAO,MAAM,QAAQ,EAC3B,EAAO,MAAM,SAKX,MAAM,EAAwB,CACtC,OAAS,EAAO,CAWf,OAVA,EAAO,MAAM,CACZ,QACA,MAAO,sCACP,MAAOA,EAAU,UAAU,aAC3B,QAAS,qCACT,KAAM,CACL,aAAc,aAAiB,MAAQ,EAAM,QAAU,OAAO,CAAK,CACpE,CACD,CAAC,EAEM,MAAM,EAAwB,CACtC,CACD"}