Skip to content

Commit c62ddaa

Browse files
authored
Merge pull request #100 from better-stack-ai/feat/media-plugin-client
fix: add foreign key references for folderId and parentId
2 parents ecfa8bb + c660bc7 commit c62ddaa

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

packages/stack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@btst/stack",
3-
"version": "2.9.2",
3+
"version": "2.9.3",
44
"description": "A composable, plugin-based library for building full-stack applications.",
55
"repository": {
66
"type": "git",

packages/stack/src/plugins/media/__tests__/plugin.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ function createVercelBlobStorageAdapter(
8484
return {
8585
type: "vercel-blob",
8686
urlHostnameSuffix: ".public.blob.vercel-storage.com",
87-
handleRequest: vi.fn(async (request, callbacks) => {
88-
const body = (await request.json()) as {
87+
handleRequest: vi.fn(async (request, body, callbacks) => {
88+
const parsedBody = (body ?? ((await request.json()) as unknown)) as {
8989
pathname?: string;
9090
clientPayload?: string | null;
9191
};
9292
const tokenOptions = await callbacks.onBeforeGenerateToken?.(
93-
body.pathname ?? "photo.jpg",
94-
body.clientPayload ?? null,
93+
parsedBody.pathname ?? "photo.jpg",
94+
parsedBody.clientPayload ?? null,
9595
);
9696
return { ok: true, tokenOptions };
9797
}),

packages/stack/src/plugins/media/db.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ export const mediaSchema = createDbPlugin("media", {
3131
folderId: {
3232
type: "string",
3333
required: false,
34+
references: {
35+
model: "mediaFolder",
36+
field: "id",
37+
},
3438
},
3539
alt: {
3640
type: "string",
@@ -52,6 +56,10 @@ export const mediaSchema = createDbPlugin("media", {
5256
parentId: {
5357
type: "string",
5458
required: false,
59+
references: {
60+
model: "mediaFolder",
61+
field: "id",
62+
},
5563
},
5664
createdAt: {
5765
type: "date",

0 commit comments

Comments
 (0)