UNPKG

universal_authentication

Version:

Seamless and Secure Authentication for Modern Web Applications: Easily integrate OTP-based email verification, Google OAuth, GitHub, Microsoft, and Okta login into your Node.js app. Modular, flexible, and database-agnostic, this package simplifies user au

23 lines (22 loc) 812 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const mongoose_1 = __importDefault(require("mongoose")); const dotenv_1 = __importDefault(require("dotenv")); dotenv_1.default.config(); // Get the MongoDB URI from environment variables const mongoURI = process.env.MONGODB_URI; // Function to connect to MongoDB const connectDB = async () => { try { await mongoose_1.default.connect(mongoURI); console.log("MongoDB connected successfully"); } catch (error) { console.error("Error connecting to MongoDB:", error); process.exit(1); // Exit the process with failure } }; exports.default = connectDB;