From 7379bf2b1b6103f588a8b25b61b456cb8d0ecbcd Mon Sep 17 00:00:00 2001 From: cameronapak Date: Wed, 16 Jul 2025 22:38:36 -0500 Subject: [PATCH 1/7] docs: add S3 setup instructions for media module --- docs/modules/media.mdx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/modules/media.mdx b/docs/modules/media.mdx index e148a79..ba63e13 100644 --- a/docs/modules/media.mdx +++ b/docs/modules/media.mdx @@ -16,3 +16,38 @@ on your environment). The media tools are designed to integrate effortlessly into your workflows, offering scalability and control without added complexity. + +### Pre-built support for S3 + +There are two ways to enable S3 or S3 compatible storage in bknd. + +1. Enable via the admin UI. + +Simply navigate to the **Media** tab of the bknd admin UI and enable the S3 media support. +Enter your AWS S3-compatible storage Access Key, Secret Access Key, and URL. +This will automatically configure the S3 adapter for you. + +2. Enable programatically. + +To enable using a code-first approach, create an [Initial Structure](/usage/database#initial-structure) using the +`initialConfig` option in your `bknd.config.ts` file. + +```typscript bknd.config.ts +import type { BkndConfig } from "bknd/adapter"; + +export default { + initialConfig: { + media: { + enabled: true, + adapter: { + type: "s3", + config: { + access_key: "", + secret_access_key: "", + url: "" + } + } + } + } +} satisfies BkndConfig; +``` From 2b6f520f46b6a8cd8603cadc79e01c8b9455ad52 Mon Sep 17 00:00:00 2001 From: cameronapak Date: Wed, 16 Jul 2025 22:41:55 -0500 Subject: [PATCH 2/7] docs: fix typos and indentation in media module docs --- docs/modules/media.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/modules/media.mdx b/docs/modules/media.mdx index ba63e13..0e413da 100644 --- a/docs/modules/media.mdx +++ b/docs/modules/media.mdx @@ -27,12 +27,12 @@ Simply navigate to the **Media** tab of the bknd admin UI and enable the S3 medi Enter your AWS S3-compatible storage Access Key, Secret Access Key, and URL. This will automatically configure the S3 adapter for you. -2. Enable programatically. +2. Enable programmatically. To enable using a code-first approach, create an [Initial Structure](/usage/database#initial-structure) using the `initialConfig` option in your `bknd.config.ts` file. -```typscript bknd.config.ts +```typescript bknd.config.ts import type { BkndConfig } from "bknd/adapter"; export default { @@ -48,6 +48,6 @@ export default { } } } - } + } } satisfies BkndConfig; -``` +``` \ No newline at end of file From 0fffa26d558bc2373724a265d984ad550f80147b Mon Sep 17 00:00:00 2001 From: cameronapak Date: Wed, 16 Jul 2025 22:47:09 -0500 Subject: [PATCH 3/7] docs: add local media adapter example for Node.js --- docs/modules/media.mdx | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/modules/media.mdx b/docs/modules/media.mdx index 0e413da..f14f7b1 100644 --- a/docs/modules/media.mdx +++ b/docs/modules/media.mdx @@ -50,4 +50,31 @@ export default { } } } satisfies BkndConfig; -``` \ No newline at end of file +``` + +### Local adapter for development + +For local development and testing, you can use the local file system adapter. This is particularly useful when working with Node.js environments. + +```typescript bknd.config.ts +import { registerLocalMediaAdapter } from "bknd/adapter/node"; +import type { BkndConfig } from "bknd/adapter"; + +// Register the local media adapter +const local = registerLocalMediaAdapter(); + +export default { + initialConfig: { + media: { + enabled: true, + adapter: local({ + path: "./public/uploads", // Files will be stored in this directory + }), + } + } +} satisfies BkndConfig; +``` + +This configuration will store uploaded files in the specified directory, +making them accessible through your application's public path or whever +you choose. From cec32ae881fae01ad24b179570ded449f20b273e Mon Sep 17 00:00:00 2001 From: cameronapak Date: Wed, 16 Jul 2025 22:57:15 -0500 Subject: [PATCH 4/7] docs(media): add S3/R2 URL format examples and fix typo --- docs/modules/media.mdx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/modules/media.mdx b/docs/modules/media.mdx index f14f7b1..4cd3897 100644 --- a/docs/modules/media.mdx +++ b/docs/modules/media.mdx @@ -25,7 +25,11 @@ There are two ways to enable S3 or S3 compatible storage in bknd. Simply navigate to the **Media** tab of the bknd admin UI and enable the S3 media support. Enter your AWS S3-compatible storage Access Key, Secret Access Key, and URL. -This will automatically configure the S3 adapter for you. +This will automatically configure the S3 adapter for you. + +**URL Format Examples:** +- **S3**: `https://{bucket}.s3.{region}.amazonaws.com` +- **R2 (Cloudflare)**: `https://{account_id}.r2.cloudflarestorage.com/{bucket}` 2. Enable programmatically. @@ -76,5 +80,5 @@ export default { ``` This configuration will store uploaded files in the specified directory, -making them accessible through your application's public path or whever +making them accessible through your application's public path or wherever you choose. From 8b832f02acc577237c9862a712e4e376386b6290 Mon Sep 17 00:00:00 2001 From: cameronapak Date: Wed, 16 Jul 2025 23:03:38 -0500 Subject: [PATCH 5/7] docs: add cross-links to initial config and seeding sections --- docs/extending/config.mdx | 2 +- docs/usage/introduction.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/extending/config.mdx b/docs/extending/config.mdx index d174b52..1684467 100644 --- a/docs/extending/config.mdx +++ b/docs/extending/config.mdx @@ -4,7 +4,7 @@ title: bknd.config.ts The central configuration file to extend bknd should be placed in the root of your project, so that the [CLI](/usage/cli#using-configuration-file-bknd-config) can automatically pick it up. It allows to: * define your database connection centrally -* pass in initial configuration or data seeds when booting the first time +* pass in [initial configuration](/usage/database#initial-structure) or [data seeds](/usage/database#seeding-the-database) when booting the first time * add plugins to the app * hook into system events * define custom routes and endpoints diff --git a/docs/usage/introduction.mdx b/docs/usage/introduction.mdx index 11ecb7e..47fc955 100644 --- a/docs/usage/introduction.mdx +++ b/docs/usage/introduction.mdx @@ -78,7 +78,7 @@ see [Custom Connection](/usage/database#custom-connection) as a reference. If the connection object is omitted, the app will try to use an in-memory database. ### `initialConfig` -As initial configuration, you can either pass a partial configuration object or a complete one +As [initial configuration](/usage/database#initial-structure), you can either pass a partial configuration object or a complete one with a version number. The version number is used to automatically migrate the configuration up to the latest version upon boot. The default configuration looks like this: From a3782728f91688dbb57238e82d297f5b76b55bd4 Mon Sep 17 00:00:00 2001 From: dswbx Date: Sat, 19 Jul 2025 08:39:19 +0200 Subject: [PATCH 6/7] indent numbered lists content, clarified media serve locations --- docs/modules/media.mdx | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/docs/modules/media.mdx b/docs/modules/media.mdx index 4cd3897..209cb42 100644 --- a/docs/modules/media.mdx +++ b/docs/modules/media.mdx @@ -23,18 +23,17 @@ There are two ways to enable S3 or S3 compatible storage in bknd. 1. Enable via the admin UI. -Simply navigate to the **Media** tab of the bknd admin UI and enable the S3 media support. -Enter your AWS S3-compatible storage Access Key, Secret Access Key, and URL. -This will automatically configure the S3 adapter for you. + Simply navigate to the **Media** tab of the bknd admin UI and enable the S3 media support. + Enter your AWS S3-compatible storage Access Key, Secret Access Key, and URL. + This will automatically configure the S3 adapter for you. -**URL Format Examples:** -- **S3**: `https://{bucket}.s3.{region}.amazonaws.com` -- **R2 (Cloudflare)**: `https://{account_id}.r2.cloudflarestorage.com/{bucket}` + **URL Format Examples:** + - **S3**: `https://{bucket}.s3.{region}.amazonaws.com` + - **R2 (Cloudflare)**: `https://{account_id}.r2.cloudflarestorage.com/{bucket}` 2. Enable programmatically. -To enable using a code-first approach, create an [Initial Structure](/usage/database#initial-structure) using the -`initialConfig` option in your `bknd.config.ts` file. + To enable using a code-first approach, create an [Initial Structure](/usage/database#initial-structure) using the `initialConfig` option in your `bknd.config.ts` file. ```typescript bknd.config.ts import type { BkndConfig } from "bknd/adapter"; @@ -80,5 +79,5 @@ export default { ``` This configuration will store uploaded files in the specified directory, -making them accessible through your application's public path or wherever -you choose. +making them accessible through your application's public path (in this case) +or at `/api/media/file/{filename}`. From f19977ac28016b1e58c1801874463b6e86b1c15f Mon Sep 17 00:00:00 2001 From: dswbx Date: Sat, 19 Jul 2025 09:12:28 +0200 Subject: [PATCH 7/7] fix mediacontroller tests --- app/__test__/_assets/.gitignore | 3 ++- app/__test__/_assets/tmp/.gitkeep | 0 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 app/__test__/_assets/tmp/.gitkeep diff --git a/app/__test__/_assets/.gitignore b/app/__test__/_assets/.gitignore index e540f5b..22bd3dc 100644 --- a/app/__test__/_assets/.gitignore +++ b/app/__test__/_assets/.gitignore @@ -1 +1,2 @@ -tmp/* \ No newline at end of file +tmp/* +!tmp/.gitkeep \ No newline at end of file diff --git a/app/__test__/_assets/tmp/.gitkeep b/app/__test__/_assets/tmp/.gitkeep new file mode 100644 index 0000000..e69de29