File uploading

This commit is contained in:
2026-10-29 17:59:34 -03:00
parent ec9bdb8e8e
commit b65d8efad8
18 changed files with 686 additions and 51 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
import { Database } from "@paulaboks/boksy";
import { Database, type Model } from "@paulaboks/boksy";
import { DATABASE_PATH } from "@/src/server_constants.ts";
import type { PassphraseBackup } from "@/src/keys.ts";
@@ -11,10 +11,25 @@ export interface User extends Record<string, unknown> {
passphrase_backup?: PassphraseBackup;
}
export interface StoredFile extends Record<string, unknown> {
user_id: string;
// Name of the encrypted file inside FILE_UPLOAD_PATH
storage_id: string;
// Size of the encrypted file
size: number;
// Encrypted by the client, holds the name, type and file key
metadata: string;
}
// boksy's partial entry types lose the field types
export type FileRow = Model & StoredFile;
type Schema = {
users: User;
files: StoredFile;
};
export const db = await Database.open<Schema>(DATABASE_PATH ?? ":memory:", {
users: ["code"],
files: ["user_id"],
});