mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-14 22:08:45 +00:00
thumbnail 테이블의 created_at 컬럼의 이름을 updated_at으로 변경
This commit is contained in:
@@ -5,7 +5,7 @@ import db from "./kysely";
|
|||||||
interface Thumbnail {
|
interface Thumbnail {
|
||||||
id: number;
|
id: number;
|
||||||
path: string;
|
path: string;
|
||||||
createdAt: Date;
|
updatedAt: Date;
|
||||||
encContentIv: string;
|
encContentIv: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ export const updateFileThumbnail = async (
|
|||||||
.values({
|
.values({
|
||||||
file_id: fileId,
|
file_id: fileId,
|
||||||
path,
|
path,
|
||||||
created_at: now,
|
updated_at: now,
|
||||||
encrypted_content_iv: encContentIv,
|
encrypted_content_iv: encContentIv,
|
||||||
})
|
})
|
||||||
.onConflict((oc) =>
|
.onConflict((oc) =>
|
||||||
oc.column("file_id").doUpdateSet({
|
oc.column("file_id").doUpdateSet({
|
||||||
path,
|
path,
|
||||||
created_at: now,
|
updated_at: now,
|
||||||
encrypted_content_iv: encContentIv,
|
encrypted_content_iv: encContentIv,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -80,7 +80,7 @@ export const getFileThumbnail = async (userId: number, fileId: number) => {
|
|||||||
fileId: thumbnail.file_id,
|
fileId: thumbnail.file_id,
|
||||||
path: thumbnail.path,
|
path: thumbnail.path,
|
||||||
encContentIv: thumbnail.encrypted_content_iv,
|
encContentIv: thumbnail.encrypted_content_iv,
|
||||||
createdAt: thumbnail.created_at,
|
updatedAt: thumbnail.updated_at,
|
||||||
} satisfies FileThumbnail)
|
} satisfies FileThumbnail)
|
||||||
: null;
|
: null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const up = async (db: Kysely<any>) => {
|
|||||||
col.references("category.id").onDelete("cascade").unique(),
|
col.references("category.id").onDelete("cascade").unique(),
|
||||||
)
|
)
|
||||||
.addColumn("path", "text", (col) => col.unique().notNull())
|
.addColumn("path", "text", (col) => col.unique().notNull())
|
||||||
.addColumn("created_at", "timestamp(3)", (col) => col.notNull())
|
.addColumn("updated_at", "timestamp(3)", (col) => col.notNull())
|
||||||
.addColumn("encrypted_content_iv", "text", (col) => col.notNull())
|
.addColumn("encrypted_content_iv", "text", (col) => col.notNull())
|
||||||
.addCheckConstraint(
|
.addCheckConstraint(
|
||||||
"thumbnail_ck01",
|
"thumbnail_ck01",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ interface ThumbnailTable {
|
|||||||
file_id: number | null;
|
file_id: number | null;
|
||||||
category_id: number | null;
|
category_id: number | null;
|
||||||
path: string;
|
path: string;
|
||||||
created_at: Date;
|
updated_at: Date;
|
||||||
encrypted_content_iv: string; // Base64
|
encrypted_content_iv: string; // Base64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export const fileRenameRequest = z.object({
|
|||||||
export type FileRenameRequest = z.infer<typeof fileRenameRequest>;
|
export type FileRenameRequest = z.infer<typeof fileRenameRequest>;
|
||||||
|
|
||||||
export const fileThumbnailInfoResponse = z.object({
|
export const fileThumbnailInfoResponse = z.object({
|
||||||
|
updatedAt: z.string().datetime(),
|
||||||
encContentIv: z.string().base64().nonempty(),
|
encContentIv: z.string().base64().nonempty(),
|
||||||
});
|
});
|
||||||
export type FileThumbnailInfoResponse = z.infer<typeof fileThumbnailInfoResponse>;
|
export type FileThumbnailInfoResponse = z.infer<typeof fileThumbnailInfoResponse>;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ export const getFileThumbnailInformation = async (userId: number, fileId: number
|
|||||||
error(404, "File or its thumbnail not found");
|
error(404, "File or its thumbnail not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
return { encContentIv: thumbnail.encContentIv };
|
return { updatedAt: thumbnail.updatedAt, encContentIv: thumbnail.encContentIv };
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFileThumbnailStream = async (userId: number, fileId: number) => {
|
export const getFileThumbnailStream = async (userId: number, fileId: number) => {
|
||||||
|
|||||||
@@ -16,8 +16,11 @@ export const GET: RequestHandler = async ({ locals, params }) => {
|
|||||||
if (!zodRes.success) error(400, "Invalid path parameters");
|
if (!zodRes.success) error(400, "Invalid path parameters");
|
||||||
const { id } = zodRes.data;
|
const { id } = zodRes.data;
|
||||||
|
|
||||||
const { encContentIv } = await getFileThumbnailInformation(userId, id);
|
const { updatedAt, encContentIv } = await getFileThumbnailInformation(userId, id);
|
||||||
return json(
|
return json(
|
||||||
fileThumbnailInfoResponse.parse({ encContentIv } satisfies FileThumbnailInfoResponse),
|
fileThumbnailInfoResponse.parse({
|
||||||
|
updatedAt: updatedAt.toISOString(),
|
||||||
|
encContentIv,
|
||||||
|
} satisfies FileThumbnailInfoResponse),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user