@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
1 lines • 2.14 kB
Source Map (JSON)
{"version":3,"file":"create-service-context.mjs","names":["constants"],"sources":["../../../src/utils/services/create-service-context.ts"],"sourcesContent":["import constants from \"../../constants/constants.js\";\nimport { passthroughEmailAdapterInstance } from \"../../libs/email/adapters/passthrough.js\";\nimport { createTranslator } from \"../../libs/i18n/index.js\";\nimport { passthroughKVAdapter } from \"../../libs/kv/index.js\";\nimport { passthroughQueueAdapter } from \"../../libs/queue/index.js\";\nimport type { CreateServiceContextOptions, ServiceContext } from \"./types.js\";\n\n/**\n * Internal helper for building service contexts outside the HTTP request pipeline.\n * HTTP service contexts resolve request metadata and locale from the Hono context.\n */\nconst createServiceContext = (\n\toptions: CreateServiceContextOptions,\n): ServiceContext => {\n\tconst locale = options.config.i18n.defaultLocale;\n\n\treturn {\n\t\tdb: {\n\t\t\tclient: options.database.client,\n\t\t},\n\t\tconfig: options.config,\n\t\tenv: options.env ?? null,\n\t\truntimeContext: options.runtimeContext,\n\t\tqueue: options.queue ?? passthroughQueueAdapter(),\n\t\tkv: options.kv ?? passthroughKVAdapter(),\n\t\tmedia: options.media ?? null,\n\t\temail: options.email ?? passthroughEmailAdapterInstance,\n\t\ttranslate: createTranslator({\n\t\t\tstore: options.translationStore,\n\t\t\tlocale,\n\t\t}),\n\t\trequest: {\n\t\t\turl:\n\t\t\t\toptions.request?.url ?? options.config.host ?? constants.urls.localhost,\n\t\t\tipAddress: options.request?.ipAddress ?? null,\n\t\t\tlocale,\n\t\t\ttenantKey: options.request?.tenantKey ?? null,\n\t\t},\n\t};\n};\n\nexport default createServiceContext;\n"],"mappings":"yTAWA,MAAM,EACL,GACoB,CACpB,IAAM,EAAS,EAAQ,OAAO,KAAK,cAEnC,MAAO,CACN,GAAI,CACH,OAAQ,EAAQ,SAAS,MAC1B,EACA,OAAQ,EAAQ,OAChB,IAAK,EAAQ,KAAO,KACpB,eAAgB,EAAQ,eACxB,MAAO,EAAQ,OAAS,EAAwB,EAChD,GAAI,EAAQ,IAAM,EAAqB,EACvC,MAAO,EAAQ,OAAS,KACxB,MAAO,EAAQ,OAAS,EACxB,UAAW,EAAiB,CAC3B,MAAO,EAAQ,iBACf,QACD,CAAC,EACD,QAAS,CACR,IACC,EAAQ,SAAS,KAAO,EAAQ,OAAO,MAAQA,EAAU,KAAK,UAC/D,UAAW,EAAQ,SAAS,WAAa,KACzC,SACA,UAAW,EAAQ,SAAS,WAAa,IAC1C,CACD,CACD"}