import dotenv from "dotenv";

import path from "path";
dotenv.config({ path: path.resolve(process.cwd(), ".env") });
// Fallback for if run from project root
if (!process.env.PORT) {
  dotenv.config({ path: path.resolve(process.cwd(), "backend", ".env") });
}

export const env = {
  port: Number(process.env.PORT || 4000),
  jwtSecret: process.env.JWT_SECRET || "change_me",
  db: {
    host: process.env.DB_HOST || "127.0.0.1",
    port: Number(process.env.DB_PORT || 3306),
    database: process.env.DB_NAME || "e_notary",
    user: process.env.DB_USER || "root",
    password: process.env.DB_PASSWORD || ""
  }
};
