From fc7473864325dfa8f806e8468a07898a49343bb1 Mon Sep 17 00:00:00 2001 From: Huskydog9988 <39809509+Huskydog9988@users.noreply.github.com> Date: Sat, 10 May 2025 16:18:28 -0400 Subject: [PATCH] feat: new unified data folder --- nuxt.config.ts | 26 +++++++++++++++----------- server/internal/clients/ca-store.ts | 4 +++- server/internal/config/sys-conf.ts | 14 ++++++++++++++ server/internal/library/index.ts | 3 ++- server/internal/objects/fsBackend.ts | 3 ++- server/plugins/ca.ts | 4 +--- 6 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 server/internal/config/sys-conf.ts diff --git a/nuxt.config.ts b/nuxt.config.ts index 440e1b5..b531bcd 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -4,6 +4,17 @@ const dropVersion = "0.3"; // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ + extends: ["./drop-base"], + + // Module config from here down + modules: [ + "vue3-carousel-nuxt", + "nuxt-security", + // "@nuxt/image", + "@nuxt/fonts", + "@nuxt/eslint", + ], + // Nuxt-only config telemetry: false, compatibilityDate: "2024-04-03", @@ -23,6 +34,10 @@ export default defineNuxtConfig({ viewTransition: true, }, + // future: { + // compatibilityVersion: 4, + // }, + vite: { plugins: [tailwindcss()], }, @@ -92,17 +107,6 @@ export default defineNuxtConfig({ }, }, - extends: ["./drop-base"], - - // Module config from here down - modules: [ - "vue3-carousel-nuxt", - "nuxt-security", - // "@nuxt/image", - "@nuxt/fonts", - "@nuxt/eslint", - ], - carousel: { prefix: "Vue", }, diff --git a/server/internal/clients/ca-store.ts b/server/internal/clients/ca-store.ts index 317515b..a424731 100644 --- a/server/internal/clients/ca-store.ts +++ b/server/internal/clients/ca-store.ts @@ -2,6 +2,7 @@ import path from "path"; import fs from "fs"; import type { CertificateBundle } from "./ca"; import prisma from "../db/database"; +import { systemConfig } from "../config/sys-conf"; export type CertificateStore = { store(name: string, data: CertificateBundle): Promise; @@ -10,7 +11,8 @@ export type CertificateStore = { checkBlacklistCertificate(name: string): Promise; }; -export const fsCertificateStore = (base: string) => { +export const fsCertificateStore = () => { + const base = path.join(systemConfig.getDataFolder(), "certs"); const blacklist = path.join(base, ".blacklist"); fs.mkdirSync(blacklist, { recursive: true }); const store: CertificateStore = { diff --git a/server/internal/config/sys-conf.ts b/server/internal/config/sys-conf.ts new file mode 100644 index 0000000..306d81e --- /dev/null +++ b/server/internal/config/sys-conf.ts @@ -0,0 +1,14 @@ +class SystemConfig { + private libraryFolder = process.env.LIBRARY ?? "./.data/library"; + private dataFolder = process.env.DATA ?? "./.data/data"; + + getLibraryFolder() { + return this.libraryFolder; + } + + getDataFolder() { + return this.dataFolder; + } +} + +export const systemConfig = new SystemConfig(); diff --git a/server/internal/library/index.ts b/server/internal/library/index.ts index 91d3b21..6556702 100644 --- a/server/internal/library/index.ts +++ b/server/internal/library/index.ts @@ -15,12 +15,13 @@ import taskHandler from "../tasks"; import { parsePlatform } from "../utils/parseplatform"; import droplet from "@drop-oss/droplet"; import notificationSystem from "../notifications"; +import { systemConfig } from "../config/sys-conf"; class LibraryManager { private basePath: string; constructor() { - this.basePath = process.env.LIBRARY ?? "./.data/library"; + this.basePath = systemConfig.getLibraryFolder(); fs.mkdirSync(this.basePath, { recursive: true }); } diff --git a/server/internal/objects/fsBackend.ts b/server/internal/objects/fsBackend.ts index 3f0b865..34e0800 100644 --- a/server/internal/objects/fsBackend.ts +++ b/server/internal/objects/fsBackend.ts @@ -7,6 +7,7 @@ import { Readable } from "stream"; import { createHash } from "crypto"; import prisma from "../db/database"; import cacheHandler from "../cache"; +import { systemConfig } from "../config/sys-conf"; export class FsObjectBackend extends ObjectBackend { private baseObjectPath: string; @@ -16,7 +17,7 @@ export class FsObjectBackend extends ObjectBackend { constructor() { super(); - const basePath = process.env.FS_BACKEND_PATH ?? "./.data/objects"; + const basePath = path.join(systemConfig.getDataFolder(), "objects"); this.baseObjectPath = path.join(basePath, "objects"); this.baseMetadataPath = path.join(basePath, "metadata"); diff --git a/server/plugins/ca.ts b/server/plugins/ca.ts index 0650f51..4f2aff2 100644 --- a/server/plugins/ca.ts +++ b/server/plugins/ca.ts @@ -9,9 +9,7 @@ export const useCertificateAuthority = () => { }; export default defineNitroPlugin(async () => { - // const basePath = process.env.CLIENT_CERTIFICATES ?? "./certs"; - // fs.mkdirSync(basePath, { recursive: true }); - // const store = fsCertificateStore(basePath); + // const store = fsCertificateStore(); ca = await CertificateAuthority.new(dbCertificateStore()); });