backend-setup-tool
Version:
A powerful CLI tool to instantly scaffold a clean and scalable Node.js/Express.js backend for SQL or NoSQL projects.
16 lines (14 loc) • 394 B
JavaScript
import { GLOBAL_ENV } from "../config/global-config.js"; // Import the global environment variables
import mongoose from "mongoose";
async function connect() {
if (mongoose.connection.readyState >= 1) {
return;
}
try {
await mongoose.connect(GLOBAL_ENV.db_url);
console.log("Connected to MongoDB");
} catch (error) {
console.error(error);
}
}
export default connect;