import path from 'node:path' import { fileURLToPath } from 'node:url' // Base directory resolution lives in its own module (no app imports) so that // both config.js and auth.js can use DATA_DIR without a circular dependency. const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) // server/paths.js is inside server/, so the project root is one level up export const ROOT_DIR = path.resolve(__dirname, '..') const DEFAULT_DATA_DIR = path.join(ROOT_DIR, 'data') const configuredDataDir = typeof process.env.SITEFORGE_DATA_DIR === 'string' ? process.env.SITEFORGE_DATA_DIR.trim() : '' export const DATA_DIR = configuredDataDir ? (path.isAbsolute(configuredDataDir) ? configuredDataDir : path.resolve(ROOT_DIR, configuredDataDir)) : DEFAULT_DATA_DIR