mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-15 20:17:22 +00:00
externalize libsql dependency to let installing env install the correct dep
Signed-off-by: dswbx <dennis.senn@gmx.ch>
This commit is contained in:
@@ -88,7 +88,7 @@ await tsup.build({
|
||||
watch,
|
||||
entry: ["src/index.ts", "src/data/index.ts", "src/core/index.ts", "src/core/utils/index.ts"],
|
||||
outDir: "dist",
|
||||
external: ["bun:test"],
|
||||
external: ["bun:test", "@libsql/client"],
|
||||
metafile: true,
|
||||
platform: "browser",
|
||||
format: ["esm", "cjs"],
|
||||
|
||||
@@ -21,7 +21,7 @@ export class AppBuiltEvent extends Event<{ app: App }> {
|
||||
export const AppEvents = { AppConfigUpdatedEvent, AppBuiltEvent } as const;
|
||||
|
||||
export type CreateAppConfig = {
|
||||
connection:
|
||||
connection?:
|
||||
| Connection
|
||||
| {
|
||||
type: "libsql";
|
||||
@@ -59,17 +59,19 @@ export class App<DB = any> {
|
||||
static create(config: CreateAppConfig) {
|
||||
let connection: Connection | undefined = undefined;
|
||||
|
||||
if (Connection.isConnection(config.connection)) {
|
||||
connection = config.connection;
|
||||
} else if (typeof config.connection === "object") {
|
||||
switch (config.connection.type) {
|
||||
case "libsql":
|
||||
connection = new LibsqlConnection(config.connection.config);
|
||||
break;
|
||||
try {
|
||||
if (Connection.isConnection(config.connection)) {
|
||||
connection = config.connection;
|
||||
} else if (typeof config.connection === "object") {
|
||||
connection = new LibsqlConnection(config.connection.config);
|
||||
} else {
|
||||
connection = new LibsqlConnection({ url: ":memory:" });
|
||||
console.warn("[!] No connection provided, using in-memory database");
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unknown connection of type ${typeof config.connection} given.`);
|
||||
} catch (e) {
|
||||
console.error("Could not create connection", e);
|
||||
}
|
||||
|
||||
if (!connection) {
|
||||
throw new Error("Invalid connection");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type Client, type Config, type InStatement, createClient } from "@libsql/client/web";
|
||||
import { type Client, type Config, type InStatement, createClient } from "@libsql/client";
|
||||
import { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
||||
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
||||
|
||||
Reference in New Issue
Block a user