import path from "node:path";

const cwd = process.cwd();
const serverRoot = path.basename(cwd) === "server" ? cwd : path.join(cwd, "server");

export const uploadsRoot = process.env.UPLOAD_DIR
  ? path.resolve(process.env.UPLOAD_DIR)
  : path.join(serverRoot, "uploads");

export const publicUploadUrl = (storageKey: string) => `/uploads/${storageKey.replace(/^\/uploads\//, "")}`;
