mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
chore: re-order backend file structure
This commit is contained in:
@@ -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(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user