Merge remote-tracking branch 'origin/refactor/ext-deps' into release/0.2.3

This commit is contained in:
dswbx
2024-12-07 09:30:06 +01:00
7 changed files with 56 additions and 56 deletions

View File

@@ -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");
}

View File

@@ -1,20 +0,0 @@
import { withApi } from "bknd/adapter/nextjs";
import type { BkndAdminProps } from "bknd/ui";
import type { InferGetServerSidePropsType } from "next";
import dynamic from "next/dynamic";
export const getServerSideProps = withApi(async (context) => {
return {
props: {
user: context.api.getUser()
}
};
});
export function adminPage(adminProps?: BkndAdminProps) {
const Admin = dynamic(() => import("bknd/ui").then((mod) => mod.Admin), { ssr: false });
return (props: InferGetServerSidePropsType<typeof getServerSideProps>) => {
if (typeof document === "undefined") return null;
return <Admin withProvider={{ user: props.user }} {...adminProps} />;
};
}

View File

@@ -1,2 +1 @@
export * from "./nextjs.adapter";
export * from "./AdminPage";

View File

@@ -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";