From 598e158738896d72d1d846ad88c77e0bd29738ab Mon Sep 17 00:00:00 2001 From: dswbx Date: Tue, 19 Nov 2024 15:10:40 +0100 Subject: [PATCH] doc update: added db setup instructions --- docs/integration/bun.mdx | 1 + docs/integration/cloudflare.mdx | 3 +- docs/integration/nextjs.mdx | 1 + docs/integration/remix.mdx | 1 + docs/mint.json | 2 +- docs/setup.mdx | 61 +++++++++++++++++++++++++++++++++ 6 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 docs/setup.mdx diff --git a/docs/integration/bun.mdx b/docs/integration/bun.mdx index 48b5a00..bfec760 100644 --- a/docs/integration/bun.mdx +++ b/docs/integration/bun.mdx @@ -33,6 +33,7 @@ Bun.serve({ console.log("Server running at http://localhost:1337"); ``` +For more information about the connection object, refer to the [Setup](/setup) guide. Run the application using Bun by executing: ```bash diff --git a/docs/integration/cloudflare.mdx b/docs/integration/cloudflare.mdx index 2088ff2..85e5912 100644 --- a/docs/integration/cloudflare.mdx +++ b/docs/integration/cloudflare.mdx @@ -11,8 +11,8 @@ and then install bknd as a dependency: -## Serve the API +## Serve the API ``` ts import { serve } from "bknd/adapter/cloudflare"; @@ -30,6 +30,7 @@ export default serve( } ); ``` +For more information about the connection object, refer to the [Setup](/setup) guide. Now run the worker: ```bash diff --git a/docs/integration/nextjs.mdx b/docs/integration/nextjs.mdx index bc9bcd0..007f94f 100644 --- a/docs/integration/nextjs.mdx +++ b/docs/integration/nextjs.mdx @@ -33,6 +33,7 @@ export default serve({ } }); ``` +For more information about the connection object, refer to the [Setup](/setup) guide. ## Enabling the Admin UI Create a file `[[...admin]].tsx` inside the `pages/admin` folder: diff --git a/docs/integration/remix.mdx b/docs/integration/remix.mdx index 054001d..900f533 100644 --- a/docs/integration/remix.mdx +++ b/docs/integration/remix.mdx @@ -30,6 +30,7 @@ const handler = serve({ export const loader = handler; export const action = handler; ``` +For more information about the connection object, refer to the [Setup](/setup) guide. ## Enabling the Admin UI Create a new splat route file at `app/routes/admin.$.tsx`: diff --git a/docs/mint.json b/docs/mint.json index 42dc00b..0e32f6d 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -72,7 +72,7 @@ "navigation": [ { "group": "Getting Started", - "pages": ["introduction", "installation"] + "pages": ["introduction", "setup"] }, { "group": "Modules", diff --git a/docs/setup.mdx b/docs/setup.mdx new file mode 100644 index 0000000..357f40e --- /dev/null +++ b/docs/setup.mdx @@ -0,0 +1,61 @@ +--- +title: 'Setup' +description: 'Preparing your environment for bknd' +--- +import InstallBknd from '/snippets/install-bknd.mdx'; + +In order to use **bknd**, you need to prepare access information to your database and install +the dependencies. + + + Connections to the database are managed using Kysely. Therefore, all its dialects are + theoretically supported. However, only the `SQLite` dialect is implemented as of now. + + +## Database +### SQLite as file +The easiest to get started is using SQLite as a file. When serving the API in the "Integrations", +the function accepts an object with connection details. To use a file, use the following: +```json +{ + "type": "sqlite", + "config": { + "file": "path/to/your/database.db" + } +} +``` +Please note that using SQLite as a file is only supported in server environments. + +### SQLite using LibSQL +Turso offers a SQLite-fork called LibSQL that runs a server around your SQLite database. To +point **bknd** to a local instance of LibSQL, [install Turso's CLI](https://docs.turso.tech/cli/introduction) and run the following command: +```bash +turso dev +``` + +The command will yield a URL. Use it in the connection object: +```json +{ + "type": "libsql", + "config": { + "url": "http://localhost:8080" + } +} +``` + +### SQLite using LibSQL on Turso +If you want to use LibSQL on Turso, [sign up for a free account](https://turso.tech/), create a database and point your +connection object to your new database: +```json +{ + "type": "libsql", + "config": { + "url": "libsql://your-database-url.turso.io", + "authToken": "your-auth-token" + } +} +``` + +## Installation +To install **bknd**, run the following command: + \ No newline at end of file