createClient() — astro Function Reference
Architecture documentation for the createClient() function in libsql-node.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 0c1764d3_13fa_429e_9010_f33c97e00546["createClient()"] 49db0359_d45e_d5a2_8e02_73df031d0a9e["libsql-node.ts"] 0c1764d3_13fa_429e_9010_f33c97e00546 -->|defined in| 49db0359_d45e_d5a2_8e02_73df031d0a9e style 0c1764d3_13fa_429e_9010_f33c97e00546 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/db/src/core/db-client/libsql-node.ts lines 10–43
export function createClient(opts: RemoteDbClientOptions) {
const { token, url: rawUrl } = opts;
let parsedUrl = new URL(rawUrl);
const options: Record<string, string> = Object.fromEntries(parsedUrl.searchParams.entries());
parsedUrl.search = '';
let url = parsedUrl.toString();
if (parsedUrl.protocol === 'memory:') {
// libSQL expects a special string in place of a URL
// for in-memory DBs.
url = ':memory:';
} else if (
parsedUrl.protocol === 'file:' &&
parsedUrl.pathname.startsWith('/') &&
!rawUrl.startsWith('file:/')
) {
// libSQL accepts relative and absolute file URLs
// for local DBs. This doesn't match the URL specification.
// Parsing `file:some.db` and `file:/some.db` should yield
// the same result, but libSQL interprets the former as
// a relative path, and the latter as an absolute path.
// This detects when such a conversion happened during parsing
// and undoes it so that the URL given to libSQL is the
// same as given by the user.
url = 'file:' + parsedUrl.pathname.substring(1);
}
const libSQLOptions = parseLibSQLConfig(options);
const client = createLibsqlClient({ ...libSQLOptions, url, authToken: token });
return drizzleLibsql(client);
}
Domain
Subdomains
Source
Frequently Asked Questions
What does createClient() do?
createClient() is a function in the astro codebase, defined in packages/db/src/core/db-client/libsql-node.ts.
Where is createClient() defined?
createClient() is defined in packages/db/src/core/db-client/libsql-node.ts at line 10.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free