{"_id":"@acefone-integrations/mongodb-connector","_rev":"6-0395275da5f4b7c43e88eefefa3a60ac","name":"@acefone-integrations/mongodb-connector","dist-tags":{"latest":"1.1.4"},"versions":{"1.0.0":{"name":"@acefone-integrations/mongodb-connector","version":"1.0.0","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","_id":"@acefone-integrations/mongodb-connector@1.0.0","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"dist":{"shasum":"900d3eb825010916cd3e40ce36ad121870cc68d8","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.0.0.tgz","fileCount":12,"integrity":"sha512-9yFMC6y+Po1NEREHssyhyxSS0E9QQ8vnYE55mZ8cSH1o/laATWawNRL7cnjBx75lQXV8woT1AKwjikp+uv9/3A==","signatures":[{"sig":"MEUCIQC/ZVDnKfPy4BC5IMA0mR6HIbYeOycUnHE1xy+EU/RGJgIgEj7yuu7ssWA2lr08dIaN8KVtXayJySH8z8EQi9I7BdY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21892},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3d28419141fdf2a60d2b7dada6ce165ed137a071","scripts":{"build":"tsc"},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"_npmVersion":"11.6.2","description":"High-performance MongoDB connection manager for Node.js microservices","directories":{},"_nodeVersion":"24.11.1","dependencies":{"winston":"^3.18.3","mongoose":"^8.19.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^24.9.1"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-connector_1.0.0_1769602869402_0.4944435302598196","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@acefone-integrations/mongodb-connector","version":"1.0.1","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","_id":"@acefone-integrations/mongodb-connector@1.0.1","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"dist":{"shasum":"3c638e85d6c4c3d3e78cfcfedf4968880dabf8c0","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.0.1.tgz","fileCount":12,"integrity":"sha512-HAilvzXoq0DmpL0pJlSDzaJSng+EwcGZlNnTPJdlYG8R74gUQiIubE4lajtyJZg9H468kCXIZrYTTj0KMVUAXA==","signatures":[{"sig":"MEQCIGG5WYLDUhS2n7k5eI6gG6umelkkC1wT5SZnFTOWnJbUAiAav1X8G9eEmna0M7v3ofLAK9byrp3B2X7ourWhlLwEjA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22969},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"75e2e9fd78ad4e02d7eaf7fa5d6e64d98d8bebf4","scripts":{"build":"tsc"},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"_npmVersion":"11.6.2","description":"High-performance MongoDB connection manager for Node.js microservices","directories":{},"_nodeVersion":"24.11.1","dependencies":{"winston":"^3.18.3","mongoose":"^8.19.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^24.9.1"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-connector_1.0.1_1770025306657_0.8506436520570111","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@acefone-integrations/mongodb-connector","version":"1.1.1","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","_id":"@acefone-integrations/mongodb-connector@1.1.1","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"dist":{"shasum":"c9bd828a0e38a09c6cc536175d22cebedfe9de16","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.1.1.tgz","fileCount":12,"integrity":"sha512-+Eh8mH0P1Q9FaU8UxtD9watJUkcER5PIBSIcujpL0Z5cWaYkfNEzpDZvLVohFqSqxZkix1aoRvgh00KgwANUZg==","signatures":[{"sig":"MEUCIHf5nlgyKB81j2RPBI5Omkj6X0PmluSV7C/qV71cwYf9AiEAqWmpxoEZ9sMTaJep7voK/8JLA6tSncPYtk2XDgk1H4o=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24770},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"09e3826431168288f5bab7af22d25b454229d5a6","scripts":{"build":"tsc"},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"_npmVersion":"11.6.2","description":"High-performance MongoDB connection manager for Node.js microservices","directories":{},"_nodeVersion":"24.11.1","dependencies":{"winston":"^3.18.3","mongoose":"^8.19.2"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3","@types/node":"^24.9.1"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-connector_1.1.1_1770029385682_0.5151218237815685","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@acefone-integrations/mongodb-connector","version":"1.1.2","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","_id":"@acefone-integrations/mongodb-connector@1.1.2","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"dist":{"shasum":"670b7ab36954ed59195632900996e27b9abb247a","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.1.2.tgz","fileCount":12,"integrity":"sha512-qJCw4qsKWLgjdAvKDh2tgKcJ3fy/sqCuQ05agPp3r7Vs2qOR/+eh5V9GPT7UD2+X7AprJb9tE8a1qHVanjGzog==","signatures":[{"sig":"MEYCIQDBVou8YY5PRLqoKi5MqjNY2Cg5ZGffLEjVXO3pWwQUVQIhAIwSu/5tCDeUbNQO1Ee1Pc9O941yXAGvfi/RWYJdphSX","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24825},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"a2669ec77c05b12072252b8b220ea2032264b414","scripts":{"build":"tsc"},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"_npmVersion":"11.6.2","description":"High-performance MongoDB connection manager for Node.js microservices","directories":{},"_nodeVersion":"24.11.1","dependencies":{"winston":"^3.18.3"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"^8.19.2","typescript":"^5.9.3","@types/node":"^24.9.1"},"peerDependencies":{"mongoose":"^8.19.2"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-connector_1.1.2_1770119722093_0.8432366757079541","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"name":"@acefone-integrations/mongodb-connector","version":"1.1.3","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","_id":"@acefone-integrations/mongodb-connector@1.1.3","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"dist":{"shasum":"2a11a162392bf77023462ab6a9cfc57105e13a1a","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.1.3.tgz","fileCount":12,"integrity":"sha512-rSYoHMpXQzdv2RmFjDbVTaH+bumyeUk6x1Wg0QJYMRX8mvOYoEDNPXndbEGxAeyOwNb4cw42cFyxGlg8mpaMWw==","signatures":[{"sig":"MEQCIHbfaL1jy0iTqk8r47XUZy1WlOFDNQ3rONKfCudN/8mSAiBIZZo00j/lNP5Z7kGYk7r8f9Bb9NHChmLE507BVTOe3Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24834},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"cfb6f99ce08b96f85fb12ad78ec0630be45adf68","scripts":{"build":"tsc"},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"_npmVersion":"11.6.2","description":"High-performance MongoDB connection manager for Node.js microservices","directories":{},"_nodeVersion":"24.11.1","dependencies":{"winston":"^3.18.3"},"_hasShrinkwrap":false,"devDependencies":{"mongoose":"^8.19.2","typescript":"^5.9.3","@types/node":"^24.9.1"},"peerDependencies":{"mongoose":"^7.0.0 || ^8.0.0"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-connector_1.1.3_1770190751737_0.1755440510652635","host":"s3://npm-registry-packages-npm-production"}},"1.1.4":{"name":"@acefone-integrations/mongodb-connector","version":"1.1.4","description":"High-performance MongoDB connection manager for Node.js microservices","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc"},"keywords":["mongodb","connection","singleton","high-performance","nodejs"],"author":{"name":"Sanyam Jain"},"license":"MIT","dependencies":{"winston":"^3.18.3"},"peerDependencies":{"mongoose":"^7.0.0 || ^8.0.0"},"devDependencies":{"@types/node":"^24.9.1","mongoose":"^8.19.2","typescript":"^5.9.3"},"gitHead":"1ad80c1b83f391d228262910075d23a6d94b4dff","_id":"@acefone-integrations/mongodb-connector@1.1.4","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-cyV/+Zmvrk6sQgGmWCvFKcMnbezz3VBQhOkVE6fkX64ljcmI7iQU4GESJtYhkeMjYeZEkWcnntYfYjaudc/URg==","shasum":"aa7f387a31e0b562c6f6b29c403fe98046134a36","tarball":"https://registry.npmjs.org/@acefone-integrations/mongodb-connector/-/mongodb-connector-1.1.4.tgz","fileCount":12,"unpackedSize":24605,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBN3zkk0LJeobuScAiugkwY9TdBtbNS7uFM3ZXvfIgE8AiEA7bfKQ5y7xJMZG7Am+DhtTVmyhwuiRe+5WS+OIbbBrgI="}]},"_npmUser":{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"},"directories":{},"maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/mongodb-connector_1.1.4_1770192167781_0.9444643418020582"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-28T12:21:09.280Z","modified":"2026-02-04T08:02:48.064Z","1.0.0":"2026-01-28T12:21:09.541Z","1.0.1":"2026-02-02T09:41:46.815Z","1.1.1":"2026-02-02T10:49:45.828Z","1.1.2":"2026-02-03T11:55:22.249Z","1.1.3":"2026-02-04T07:39:11.883Z","1.1.4":"2026-02-04T08:02:47.948Z"},"author":{"name":"Sanyam Jain"},"license":"MIT","keywords":["mongodb","connection","singleton","high-performance","nodejs"],"description":"High-performance MongoDB connection manager for Node.js microservices","maintainers":[{"name":"acefone-integration","email":"integrationdeveloper@acefone.com"}],"readme":"# MongoDB Connector\n\nA high-performance, singleton MongoDB connection manager for Node.js microservices, built with Mongoose and TypeScript.\n\n## Features\n\n- **Singleton Pattern**: Ensures a single active database connection per process.\n- **Connection Pooling**: Optimized default settings for pool size, timeouts, and keep-alive.\n- **Graceful Shutdown**: Automatically handles `SIGINT` and `SIGTERM` to close connections properly.\n- **Flexible Configuration**: Connect via a full URI or individual parameters (`host`, `port`, `dbName`, etc.).\n- **TypeScript Support**: Full type definitions included.\n\n## Installation\n\nSince this is a local package, you can install it in other repositories using one of the following methods:\nor when deployed\n\n```bash\nnpm install mongo-connector\n```\n\n### Option 1: Install via Local Path (Recommended)\nRefer to the package directory directly in your `npm install` command:\n```bash\nnpm install /path/to/mongo-connector\n```\n*Note: You must rebuild this package (`npm run build`) for changes to take effect in consuming projects.*\n\n### Option 2: NPM Link (For Development)\n1. In this directory (`mongo-connector`):\n   ```bash\n   npm link\n   ```\n2. In your target project:\n   ```bash\n   npm link mongodb-connector\n   ```\n\n## Usage\n\n### 1. Initialization\nInitialize the connection at the start of your application. You must provide a configuration object(Example given below).\n\n```typescript\nimport { MongoConnection } from 'mongodb-connector';\n\nasync function bootstrap() {\n  await MongoConnection.getInstance({\n    // Option A: URI\n    uri: \"mongodb://localhost:27017/my-database\",\n    options: {\n        appName: \"my-service\"\n    }\n  });\n  \n```\n\n### 2. Accessing the Connection\nOnce initialized, you can retrieve the active connection instance anywhere in your app:\n\n```typescript\nconst connection = MongoConnection.getInstance();\n// returns Promise<MongoConnection>\n```\n\nTo get the raw Mongoose connection object:\n```typescript\nconst conn = (await MongoConnection.getInstance()).getConnection();\n```\n\n## Configuration Options\n\nThe `MongoConfig` interface supports the following:\n\n| Parameter | Type | Required | Description |\n|-----------|------|----------|-------------|\n| `uri` | string | **Yes** | Full MongoDB connection string. |\n| `options.appName` | string | **Yes** | Identifier for the application (for monitoring). |\n| `options.maxPoolSize` | number | No | Max number of connections in the pool. Default: 5. |\n| `options.minPoolSize` | number | No | Min number of connections in the pool. Default: 0. |\n| `options.maxIdleTimeMS` | number | No | Close idle connections after this time (ms). Default: 30000. |\n| `options.connectTimeoutMS` | number | No | Fail if initial connection takes longer than this (ms). Default: 10000. |\n| `options.socketTimeoutMS` | number | No | Socket inactivity timeout (ms). Default: 10000. |\n| `options.serverSelectionTimeoutMS` | number | No | Max wait to find a working server (ms). Default: 15000. |\n| `options.tls` | boolean | No | Enable TLS for secure connections. Default: true. |\n| `options.directConnection` | boolean | No | Use direct connection instead of replica discovery. Default: false. |\n\n### Default Optimization\nThe connector comes with production-ready defaults:\n- **Pool Size**: Max 5, Min 0 (configurable).\n- **Timeouts**: optimized for fail-fast behavior.\n- **TLS**: Enabled by default (set `tls: false` if needed for local dev without SSL).\n- **Compression**: snappy/zstd enabled if available.\n\n## Build\nTo compile the TypeScript source:\n```bash\nnpm run build\n```","readmeFilename":"README.md"}