import mongoose from "mongoose";
import { dirname, resolve } from "path";
import * as dotenv from "dotenv";
import { fileURLToPath } from "url";

dotenv.config({ path: resolve(dirname(fileURLToPath(new URL(import.meta.url))), "../.env") });
export const hasMigrated = false;
export const uri =
	process.env.NODE_ENV === "production" && !process.env.TEST
		? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/${process.env.DB_NAME}?authSource=admin`
		: `mongodb://127.0.0.1/${process.env.DB_NAME}`;
export const olduri =
	process.env.NODE_ENV === "production" && !process.env.TEST
		? `mongodb://${process.env.DBUSER}:${process.env.DBPASS}@127.0.0.1:27017/rockfic_old?authSource=admin`
		: `mongodb://127.0.0.1/rockfic_old?authSource=admin`;
!mongoose.connection.modelNames().length && mongoose.connect(uri);
