mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
update app create config to accept libsql config directly
This commit is contained in:
@@ -30,9 +30,11 @@ export type CreateAppConfig = {
|
||||
connection?:
|
||||
| Connection
|
||||
| {
|
||||
// @deprecated
|
||||
type: "libsql";
|
||||
config: LibSqlCredentials;
|
||||
};
|
||||
}
|
||||
| LibSqlCredentials;
|
||||
initialConfig?: InitialModuleConfigs;
|
||||
plugins?: AppPlugin[];
|
||||
options?: Omit<ModuleManagerOptions, "initial" | "onUpdated">;
|
||||
@@ -179,7 +181,14 @@ export function createApp(config: CreateAppConfig = {}) {
|
||||
if (Connection.isConnection(config.connection)) {
|
||||
connection = config.connection;
|
||||
} else if (typeof config.connection === "object") {
|
||||
connection = new LibsqlConnection(config.connection.config);
|
||||
if ("type" in config.connection) {
|
||||
console.warn(
|
||||
"[WARN] Using deprecated connection type 'libsql', use the 'config' object directly."
|
||||
);
|
||||
connection = new LibsqlConnection(config.connection.config);
|
||||
} else {
|
||||
connection = new LibsqlConnection(config.connection);
|
||||
}
|
||||
} else {
|
||||
connection = new LibsqlConnection({ url: ":memory:" });
|
||||
console.warn("[!] No connection provided, using in-memory database");
|
||||
|
||||
@@ -104,7 +104,7 @@ async function action(options: {
|
||||
let app: App;
|
||||
if (options.dbUrl || !configFilePath) {
|
||||
const connection = options.dbUrl
|
||||
? { type: "libsql" as const, config: { url: options.dbUrl, authToken: options.dbToken } }
|
||||
? { url: options.dbUrl, authToken: options.dbToken }
|
||||
: undefined;
|
||||
app = await makeApp({ connection, server: { platform: options.server } });
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 { type DatabaseIntrospector, Kysely, ParseJSONResultsPlugin } from "kysely";
|
||||
import { FilterNumericKeysPlugin } from "../plugins/FilterNumericKeysPlugin";
|
||||
import { KyselyPluginRunner } from "../plugins/KyselyPluginRunner";
|
||||
import type { QB } from "./Connection";
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
export { App, createApp, AppEvents, type AppConfig, type CreateAppConfig } from "./App";
|
||||
export {
|
||||
App,
|
||||
createApp,
|
||||
AppEvents,
|
||||
type AppConfig,
|
||||
type CreateAppConfig,
|
||||
type AppPlugin
|
||||
} from "./App";
|
||||
|
||||
export {
|
||||
getDefaultConfig,
|
||||
@@ -6,7 +13,8 @@ export {
|
||||
type ModuleConfigs,
|
||||
type ModuleSchemas,
|
||||
type ModuleManagerOptions,
|
||||
type ModuleBuildContext
|
||||
type ModuleBuildContext,
|
||||
type InitialModuleConfigs
|
||||
} from "./modules/ModuleManager";
|
||||
|
||||
export * as middlewares from "modules/middlewares";
|
||||
|
||||
@@ -32,10 +32,7 @@ export default {
|
||||
async fetch(request: Request) {
|
||||
if (!app || recreate) {
|
||||
app = App.create({
|
||||
connection: {
|
||||
type: "libsql",
|
||||
config: credentials
|
||||
},
|
||||
connection: credentials,
|
||||
initialConfig
|
||||
});
|
||||
app.emgr.onEvent(
|
||||
|
||||
Reference in New Issue
Block a user