mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
feat: shared type package
This commit is contained in:
@@ -1,34 +1,7 @@
|
||||
import { type } from "arktype";
|
||||
import type { volumeConfigSchema } from "@ironmount/schemas";
|
||||
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 >= 1",
|
||||
version: "'3' | '4' | '4.1'",
|
||||
});
|
||||
|
||||
const smbConfigSchema = type({
|
||||
backend: "'smb'",
|
||||
});
|
||||
|
||||
const directoryConfigSchema = type({
|
||||
backend: "'directory'",
|
||||
});
|
||||
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user