@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 2.16 kB
Source Map (JSON)
{"version":3,"file":"create-service-context.mjs","names":["constants"],"sources":["../../../../src/libs/http/utils/create-service-context.ts"],"sourcesContent":["import constants from \"../../../constants/constants.js\";\nimport type { LucidHonoContext } from \"../../../types/hono.js\";\nimport type { ServiceContext } from \"../../../utils/services/types.js\";\nimport { createTranslator, resolveInterfaceLocale } from \"../../i18n/index.js\";\n\n/**\n * A helper to build the service context from a Hono context.\n */\nconst createServiceContext = (c: LucidHonoContext): ServiceContext => {\n\tconst connectionInfo = c.get(\"runtimeContext\").getConnectionInfo(c);\n\tconst config = c.get(\"config\");\n\tconst env = c.get(\"env\");\n\tconst runtimeContext = c.get(\"runtimeContext\");\n\tconst db = { client: c.get(\"database\").client };\n\n\tconst locale = resolveInterfaceLocale({\n\t\tconfig,\n\t\tlocale: c.req.header(constants.headers.interfaceLocale),\n\t\tacceptLanguage: c.req.header(\"Accept-Language\"),\n\t});\n\tconst request = {\n\t\turl: c.req.url,\n\t\tipAddress: connectionInfo.address ?? null,\n\t\tlocale,\n\t\ttenantKey: c.get(\"tenant\")?.key ?? null,\n\t};\n\n\treturn {\n\t\tdb,\n\t\tconfig,\n\t\tqueue: c.get(\"queue\"),\n\t\tenv,\n\t\truntimeContext,\n\t\tkv: c.get(\"kv\"),\n\t\tmedia: c.get(\"media\"),\n\t\temail: c.get(\"email\"),\n\t\ttranslate: createTranslator({ store: c.get(\"translationStore\"), locale }),\n\t\trequest,\n\t};\n};\n\nexport default createServiceContext;\n"],"mappings":"wIAQA,MAAM,EAAwB,GAAwC,CACrE,IAAM,EAAiB,EAAE,IAAI,gBAAgB,CAAC,CAAC,kBAAkB,CAAC,EAC5D,EAAS,EAAE,IAAI,QAAQ,EACvB,EAAM,EAAE,IAAI,KAAK,EACjB,EAAiB,EAAE,IAAI,gBAAgB,EACvC,EAAK,CAAE,OAAQ,EAAE,IAAI,UAAU,CAAC,CAAC,MAAO,EAExC,EAAS,EAAuB,CACrC,SACA,OAAQ,EAAE,IAAI,OAAOA,EAAU,QAAQ,eAAe,EACtD,eAAgB,EAAE,IAAI,OAAO,iBAAiB,CAC/C,CAAC,EACK,EAAU,CACf,IAAK,EAAE,IAAI,IACX,UAAW,EAAe,SAAW,KACrC,SACA,UAAW,EAAE,IAAI,QAAQ,CAAC,EAAE,KAAO,IACpC,EAEA,MAAO,CACN,KACA,SACA,MAAO,EAAE,IAAI,OAAO,EACpB,MACA,iBACA,GAAI,EAAE,IAAI,IAAI,EACd,MAAO,EAAE,IAAI,OAAO,EACpB,MAAO,EAAE,IAAI,OAAO,EACpB,UAAW,EAAiB,CAAE,MAAO,EAAE,IAAI,kBAAkB,EAAG,QAAO,CAAC,EACxE,SACD,CACD"}