Function: applyLakebaseEnv()
applyLakebaseEnv(
config?,signal?):Promise<{resolved:LakebaseConnection;user?:string; }>
Resolve the connection AND apply every Postgres env var a Lakebase pool needs, returning the resolved connection plus the username that was applied.
This is the whole set, which is the point of having one function for it:
createLakebasePool() throws unless LAKEBASE_ENDPOINT, PGHOST,
PGDATABASE, and a username (PGUSER, or DATABRICKS_CLIENT_ID for a
service principal) are all present, and a Databricks App postgres resource
binding supplies only the first. Anything that wants a working pool - the
lakebase plugin, or AppKit’s PERSISTENT cache, which quietly degrades to
in-memory when the pool cannot be built - needs all four, so callers should not
pair applyLakebaseToEnv with their own username lookup.
PGUSER is applied with ??= like the rest, so an explicitly configured value
stays authoritative. The lookup returns undefined rather than throwing when it
cannot determine a user, leaving the pool to resolve its own.
Parameters
Section titled “Parameters”config?
Section titled “config?”signal?
Section titled “signal?”AbortSignal
Returns
Section titled “Returns”Promise<{ resolved: LakebaseConnection; user?: string; }>
Example
Section titled “Example”import { lakebaseResolver } from "@dbx-tools/appkit";
// Enough for `createLakebasePool()` to build a pool.const { user } = await lakebaseResolver.applyLakebaseEnv({ autoCreate: false });