npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@derikhie/mongoquick

v2.1.0

Published

⚡ Smart MongoDB connection management with profiles, testing, and database initialization

Readme

MongoQuick ⚡

Smart MongoDB connection management with profiles, testing, and database initialization

Zero-config MongoDB connection management and database setup. Switch between environments instantly, test connections with detailed diagnostics, and initialize databases with confidence.

🚀 Quick Start

npm install -g @derikhie/mongoquick
mongoquick profile add --name local --uri mongodb://localhost:27017
mongoquick profile list

✨ What It Does

🔗 Smart Connection Management: Save and switch between multiple MongoDB environments instantly

🧪 Connection Testing: Verify connectivity with detailed health diagnostics including latency, topology, and server version

📊 Database Setup: Create and initialize MongoDB databases with proper configuration

🔒 Secure Storage: Encrypted credential storage with AES-256-CBC encryption

📋 Commands

Profile Management

mongoquick profile add --name <name> --uri <uri> [options]    # Add connection profile
mongoquick profile list [--verbose] [--json]                 # List all profiles
mongoquick profile use <profile-name>                        # Switch to profile
mongoquick profile test [profile-name] [--verbose]           # Test connections
mongoquick profile current                                   # Show current profile
mongoquick profile remove <profile-name> [--force]          # Remove profile
mongoquick profile export                                    # Export profiles

Database Operations

mongoquick                    # Interactive setup wizard
mongoquick test               # Test current connection
mongoquick init --database   # Initialize database
mongoquick help               # Show all commands

🎯 Usage Examples

Environment Management

# Add your development environment
mongoquick profile add --name dev --uri mongodb://localhost:27017 --env development

# Add staging with database specification
mongoquick profile add --name staging --uri mongodb://staging.company.com:27017 --database myapp_staging --env staging

# Add production (Atlas)
mongoquick profile add --name prod --uri mongodb+srv://cluster.mongodb.net --env production --default

# Switch between environments instantly
mongoquick profile use dev     # Switch to development
mongoquick profile use prod    # Switch to production

Connection Testing

# Test current environment
mongoquick profile test

# Test specific environment
mongoquick profile test prod

# Test all environments with details
mongoquick profile test --verbose

Profile Management

# List all your environments
mongoquick profile list
┌─────────────────────────────────────────────┐
│  MongoQuick Profiles (3)                   │
├─────────────────────────────────────────────┤
│  🌟 prod      🟥 production               │
│      URI: mongodb+srv://***:***@cluster... │
│      Database: myapp                       │
│                                             │
│     staging   🟨 staging                   │
│      URI: mongodb://staging.company...     │
│      Database: myapp_staging               │
│                                             │
│     dev       🟦 development               │
│      URI: mongodb://localhost:27017        │
└─────────────────────────────────────────────┘

# Show current environment
mongoquick profile current

🔧 Framework Integration

NestJS

import { MongooseModule } from '@nestjs/mongoose';

// Use your MongoQuick profile
@Module({
  imports: [MongooseModule.forRoot('mongodb://localhost:27017/myapp')],
})
export class AppModule {}

Express with Mongoose

const mongoose = require('mongoose');
// Connect using your MongoQuick profile
mongoose.connect('mongodb://localhost:27017/myapp');

Pure MongoDB Driver

const { MongoClient } = require('mongodb');
const client = new MongoClient('mongodb://localhost:27017');
await client.db('myapp').collection('users').findOne({});

🛠️ Programmatic API

import { initializeMongo, testConnection } from '@derikhie/mongoquick';

// Test connection health
const health = await testConnection();
console.log('Connected:', health.isConnected);
console.log('Latency:', health.latency + 'ms');

// Initialize database
await initializeMongo({
  config: {
    uri: 'mongodb://localhost:27017',
    database: 'myapp',
  },
  createDatabase: true,
  verbose: true,
});

⚙️ Environment Configuration

Create a .env file for default settings:

MONGODB_URI=mongodb://localhost:27017
DATABASE_NAME=myapp
MONGOQUICK_KEY=your-encryption-key

The toolkit automatically detects these variables and uses them as defaults.

✨ Features

🎯 Smart Environment Detection: Automatically detects environment from profile names and URIs

🔐 Secure Credential Storage: AES-256-CBC encryption keeps your credentials safe

⚡ Fast Connection Testing: Concurrent testing with detailed diagnostics

🎨 Beautiful CLI: Intuitive interface with helpful error messages and suggestions

📊 Rich Diagnostics: Server version, topology, latency, and connection count

🔄 Environment Switching: One command to switch between dev, staging, and production

🏗️ Add Options

mongoquick profile add [options]

Options:
  --name, -n        Profile name (required)
  --uri, -u         MongoDB URI (required)
  --database, -d    Default database name
  --env, -e         Environment (local, dev, staging, prod)
  --default         Set as default profile

🧪 Connection Health

MongoQuick provides comprehensive connection diagnostics:

  • Connection Status: Success/failure with detailed error messages
  • Latency: Real-time connection speed measurement
  • 🏗️ Topology: Single, ReplicaSet, or Sharded cluster detection
  • 📝 Server Version: MongoDB version information
  • 🔢 Active Connections: Current connection pool status
  • 🔁 Replica Set: Primary/secondary status and replica set name

🔒 Security

  • Encrypted Storage: All URIs encrypted with AES-256-CBC
  • Credential Masking: Passwords never shown in output or logs
  • Secure Defaults: Safe file permissions and storage locations
  • No Network Leakage: Credentials never transmitted unencrypted

📋 Requirements

  • Node.js 16 or higher
  • MongoDB 4.4 or higher (local or remote)
  • Write access to home directory (for profile storage)

🚨 Troubleshooting

Connection Failed: Ensure MongoDB is running

# macOS
brew services start mongodb-community

# Linux
sudo systemctl start mongod

# Docker
docker run -d -p 27017:27017 mongo

Permission Denied: Check database user permissions or use admin credentials

Profile Not Found: Use mongoquick profile list to see available profiles


Smart MongoDB connection management for developers who want environment switching to just work.