UNPKG

@lucidcms/core

Version:

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

57 lines (56 loc) 2.69 kB
import { TranslationBundles, TranslationStore } from "../i18n/types.mjs"; import { HttpExtension } from "../http/types.mjs"; import { Config } from "../../types/config.mjs"; import { AdapterRuntimeContext, DatabaseConnectionScope, EnvironmentVariables, LucidConfigDefinition, LucidConfigDefinitionMeta } from "./types.mjs"; import { ServiceContext } from "../../utils/services/types.mjs"; import createApp from "../http/app.mjs"; import { CreateToolkitServiceContextOptions, Toolkit } from "../toolkit/types.mjs"; import z from "zod"; //#region src/libs/runtime/create-lucid-host.d.ts type CreateLucidHostSharedOptions = { runtimeContext: AdapterRuntimeContext; http?: { extensions?: HttpExtension[]; }; /** Determines who owns live database connections created by this host. */ databaseScope: DatabaseConnectionScope; }; /** Options used to create a Lucid instance within another framework or host. */ type CreateLucidHostOptions = CreateLucidHostSharedOptions & ({ definition: LucidConfigDefinition; envSchema?: z.ZodType; env?: EnvironmentVariables; translationBundles?: TranslationBundles; meta?: LucidConfigDefinitionMeta; } | { config: Config; translationStore: TranslationStore; env?: EnvironmentVariables; }); /** One request, scheduled event or other runtime invocation of a Lucid host. */ type LucidInvocation = { /** Returns the fully initialized service context for this invocation. */getServiceContext(request?: CreateToolkitServiceContextOptions["request"]): Promise<ServiceContext>; /** Returns a public toolkit backed by this invocation. */ getToolkit(request?: CreateToolkitServiceContextOptions["request"]): Promise<Toolkit>; /** Handles an HTTP request using this invocation's database connection. */ handle(options: { request: Request; executionContext?: unknown; requestBindings?: object; }): Promise<Response>; /** Releases resources owned by this invocation. */ destroy(): Promise<void>; }; /** An initialized Lucid application host owned by an external runtime. */ type LucidHost = { config: Config; env?: EnvironmentVariables; runtimeContext: AdapterRuntimeContext; translationStore: TranslationStore; issues: Awaited<ReturnType<typeof createApp>>["issues"]; createInvocation(options?: { env?: EnvironmentVariables; }): LucidInvocation; destroy(): Promise<void>; }; /** Creates a fully initialized application host with explicit invocation lifecycles. */ declare const createLucidHost: (options: CreateLucidHostOptions) => Promise<LucidHost>; //#endregion export { CreateLucidHostOptions, LucidHost, LucidInvocation, createLucidHost as default }; //# sourceMappingURL=create-lucid-host.d.mts.map