chore: re-order backend file structure

This commit is contained in:
Nicolas Meienberger
2025-08-31 17:32:11 +02:00
parent a16fc37b44
commit 23f47bbb6b
28 changed files with 240 additions and 1129 deletions

View File

@@ -2,12 +2,19 @@ import { type } from "arktype";
import { sql } from "drizzle-orm";
import { int, sqliteTable, text } from "drizzle-orm/sqlite-core";
const BACKEND_TYPES = {
nfs: "nfs",
smb: "smb",
directory: "directory",
};
export type BackendType = keyof typeof BACKEND_TYPES;
const nfsConfigSchema = type({
backend: "'nfs'",
server: "string",
exportPath: "string",
port: "number",
version: type.enumerated(["3", "4"]),
version: "string", // Shold be an enum: "3" | "4" | "4.1"
});
const smbConfigSchema = type({
@@ -18,10 +25,12 @@ const directoryConfigSchema = type({
backend: "'directory'",
});
const configSchema = nfsConfigSchema
export const volumeConfigSchema = nfsConfigSchema
.or(smbConfigSchema)
.or(directoryConfigSchema);
export type BackendConfig = typeof volumeConfigSchema.infer;
export const volumesTable = sqliteTable("volumes_table", {
id: int().primaryKey({ autoIncrement: true }),
name: text().notNull().unique(),
@@ -30,6 +39,6 @@ export const volumesTable = sqliteTable("volumes_table", {
createdAt: int("created_at").notNull().default(sql`(current_timestamp)`),
updatedAt: int("updated_at").notNull().default(sql`(current_timestamp)`),
config: text("config", { mode: "json" })
.$type<typeof configSchema.inferOut>()
.$type<typeof volumeConfigSchema.inferOut>()
.notNull(),
});