mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +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,
|
watch,
|
||||||
entry: ["src/index.ts", "src/data/index.ts", "src/core/index.ts", "src/core/utils/index.ts"],
|
entry: ["src/index.ts", "src/data/index.ts", "src/core/index.ts", "src/core/utils/index.ts"],
|
||||||
outDir: "dist",
|
outDir: "dist",
|
||||||
external: ["bun:test"],
|
external: ["bun:test", "@libsql/client"],
|
||||||
metafile: true,
|
metafile: true,
|
||||||
platform: "browser",
|
platform: "browser",
|
||||||
format: ["esm", "cjs"],
|
format: ["esm", "cjs"],
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export class AppBuiltEvent extends Event<{ app: App }> {
|
|||||||
export const AppEvents = { AppConfigUpdatedEvent, AppBuiltEvent } as const;
|
export const AppEvents = { AppConfigUpdatedEvent, AppBuiltEvent } as const;
|
||||||
|
|
||||||
export type CreateAppConfig = {
|
export type CreateAppConfig = {
|
||||||
connection:
|
connection?:
|
||||||
| Connection
|
| Connection
|
||||||
| {
|
| {
|
||||||
type: "libsql";
|
type: "libsql";
|
||||||
@@ -59,17 +59,19 @@ export class App<DB = any> {
|
|||||||
static create(config: CreateAppConfig) {
|
static create(config: CreateAppConfig) {
|
||||||
let connection: Connection | undefined = undefined;
|
let connection: Connection | undefined = undefined;
|
||||||
|
|
||||||
if (Connection.isConnection(config.connection)) {
|
try {
|
||||||
connection = config.connection;
|
if (Connection.isConnection(config.connection)) {
|
||||||
} else if (typeof config.connection === "object") {
|
connection = config.connection;
|
||||||
switch (config.connection.type) {
|
} else if (typeof config.connection === "object") {
|
||||||
case "libsql":
|
connection = new LibsqlConnection(config.connection.config);
|
||||||
connection = new LibsqlConnection(config.connection.config);
|
} else {
|
||||||
break;
|
connection = new LibsqlConnection({ url: ":memory:" });
|
||||||
|
console.warn("[!] No connection provided, using in-memory database");
|
||||||
}
|
}
|
||||||
} else {
|
} catch (e) {
|
||||||
throw new Error(`Unknown connection of type ${typeof config.connection} given.`);
|
console.error("Could not create connection", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
throw new Error("Invalid 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 { LibsqlDialect } from "@libsql/kysely-libsql";
|
||||||
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
import { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin, sql } from "kysely";
|
||||||
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
||||||
|
|||||||
Reference in New Issue
Block a user