Skip to content

Commit ac7ef63

Browse files
Huskydog9988DecDuck
authored andcommitted
feat: new unified data folder
1 parent efbc86e commit ac7ef63

File tree

6 files changed

+37
-17
lines changed

6 files changed

+37
-17
lines changed

nuxt.config.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ import tailwindcss from "@tailwindcss/vite";
22

33
// https://nuxt.com/docs/api/configuration/nuxt-config
44
export default defineNuxtConfig({
5+
extends: ["./drop-base"],
6+
7+
// Module config from here down
8+
modules: [
9+
"vue3-carousel-nuxt",
10+
"nuxt-security",
11+
// "@nuxt/image",
12+
"@nuxt/fonts",
13+
"@nuxt/eslint",
14+
],
15+
516
// Nuxt-only config
617
telemetry: false,
718
compatibilityDate: "2024-04-03",
@@ -21,6 +32,10 @@ export default defineNuxtConfig({
2132
viewTransition: true,
2233
},
2334

35+
// future: {
36+
// compatibilityVersion: 4,
37+
// },
38+
2439
vite: {
2540
plugins: [tailwindcss()],
2641
},
@@ -76,17 +91,6 @@ export default defineNuxtConfig({
7691
},
7792
},
7893

79-
extends: ["./drop-base"],
80-
81-
// Module config from here down
82-
modules: [
83-
"vue3-carousel-nuxt",
84-
"nuxt-security",
85-
// "@nuxt/image",
86-
"@nuxt/fonts",
87-
"@nuxt/eslint",
88-
],
89-
9094
carousel: {
9195
prefix: "Vue",
9296
},

server/internal/clients/ca-store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "path";
22
import fs from "fs";
33
import type { CertificateBundle } from "./ca";
44
import prisma from "../db/database";
5+
import { systemConfig } from "../config/sys-conf";
56

67
export type CertificateStore = {
78
store(name: string, data: CertificateBundle): Promise<void>;
@@ -10,7 +11,8 @@ export type CertificateStore = {
1011
checkBlacklistCertificate(name: string): Promise<boolean>;
1112
};
1213

13-
export const fsCertificateStore = (base: string) => {
14+
export const fsCertificateStore = () => {
15+
const base = path.join(systemConfig.getDataFolder(), "certs");
1416
const blacklist = path.join(base, ".blacklist");
1517
fs.mkdirSync(blacklist, { recursive: true });
1618
const store: CertificateStore = {

server/internal/config/sys-conf.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class SystemConfig {
2+
private libraryFolder = process.env.LIBRARY ?? "./.data/library";
3+
private dataFolder = process.env.DATA ?? "./.data/data";
4+
5+
getLibraryFolder() {
6+
return this.libraryFolder;
7+
}
8+
9+
getDataFolder() {
10+
return this.dataFolder;
11+
}
12+
}
13+
14+
export const systemConfig = new SystemConfig();

server/internal/library/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import taskHandler from "../tasks";
1515
import { parsePlatform } from "../utils/parseplatform";
1616
import droplet from "@drop-oss/droplet";
1717
import notificationSystem from "../notifications";
18+
import { systemConfig } from "../config/sys-conf";
1819

1920
class LibraryManager {
2021
private basePath: string;
2122

2223
constructor() {
23-
this.basePath = process.env.LIBRARY ?? "./.data/library";
24+
this.basePath = systemConfig.getLibraryFolder();
2425
fs.mkdirSync(this.basePath, { recursive: true });
2526
}
2627

server/internal/objects/fsBackend.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Readable } from "stream";
77
import { createHash } from "crypto";
88
import prisma from "../db/database";
99
import cacheHandler from "../cache";
10+
import { systemConfig } from "../config/sys-conf";
1011

1112
export class FsObjectBackend extends ObjectBackend {
1213
private baseObjectPath: string;
@@ -16,7 +17,7 @@ export class FsObjectBackend extends ObjectBackend {
1617

1718
constructor() {
1819
super();
19-
const basePath = process.env.FS_BACKEND_PATH ?? "./.data/objects";
20+
const basePath = path.join(systemConfig.getDataFolder(), "objects");
2021
this.baseObjectPath = path.join(basePath, "objects");
2122
this.baseMetadataPath = path.join(basePath, "metadata");
2223

server/plugins/ca.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ export const useCertificateAuthority = () => {
99
};
1010

1111
export default defineNitroPlugin(async () => {
12-
// const basePath = process.env.CLIENT_CERTIFICATES ?? "./certs";
13-
// fs.mkdirSync(basePath, { recursive: true });
14-
// const store = fsCertificateStore(basePath);
12+
// const store = fsCertificateStore();
1513

1614
ca = await CertificateAuthority.new(dbCertificateStore());
1715
});

0 commit comments

Comments
 (0)