fix: improve path resolution compatibility

Update path resolution logic to handle both ESM and CJS environments safely, ensuring compatibility during build processes and runtime execution.
This commit is contained in:
Dada1981 2026-06-11 22:48:21 +02:00
parent 95f32a5c95
commit 29c086779b

View file

@ -9,8 +9,13 @@ import { AuthorData } from "./src/types.js";
dotenv.config(); dotenv.config();
const __filename = fileURLToPath(import.meta.url); const currentFilename = typeof import.meta !== "undefined" && import.meta.url
const __dirname = path.dirname(__filename); ? fileURLToPath(import.meta.url)
: (typeof __filename !== "undefined" ? __filename : "");
const currentDirname = typeof import.meta !== "undefined" && import.meta.url
? path.dirname(currentFilename)
: (typeof __dirname !== "undefined" ? __dirname : "");
const app = express(); const app = express();
const PORT = 3000; const PORT = 3000;