{"_id":"@allmightypush/push-storage-mongo","name":"@allmightypush/push-storage-mongo","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@allmightypush/push-storage-mongo","version":"1.0.0","description":"MongoDB storage adapter for push notification library","main":"dist/cjs/index.js","module":"dist/esm/index.js","types":"dist/types/index.d.ts","exports":{".":{"require":"./dist/cjs/index.js","import":"./dist/esm/index.js","types":"./dist/types/index.d.ts"}},"scripts":{"build":"npm run build:cjs && npm run build:esm && npm run build:types","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","test":"jest --passWithNoTests","test:watch":"jest --watch","test:coverage":"jest --coverage --passWithNoTests","clean":"rm -rf dist"},"keywords":["push","notification","storage","mongodb","mongo"],"author":{"name":"Samtes64"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-mongo"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-mongo#readme","dependencies":{"@allmightypush/push-core":"^1.0.0","mongodb":"^6.3.0"},"engines":{"node":">=16.0.0"},"_id":"@allmightypush/push-storage-mongo@1.0.0","gitHead":"8d7b012f519f95515344d9b5c96d4ba42039046b","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-IhoRw7un5YNNRxsVpdnOMgQ51/dhCWrP2WFKAqBmkIL7dXJ7Sd1PnRfLXSV9vzFhjzrKNJ3biwhHW/ZnyZsQbA==","shasum":"6885c1537121206542115950a9a29df68827dc81","tarball":"https://registry.npmjs.org/@allmightypush/push-storage-mongo/-/push-storage-mongo-1.0.0.tgz","fileCount":8,"unpackedSize":40836,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBc2c8230Z0a6EcZSB+UGEZdYGkxWIRwEB1fe7kkBxi6AiB63/9bIqwd+FFBi/3Veo/MVmKy4dH9InskW68mWHuZxQ=="}]},"_npmUser":{"name":"samtes64","email":"samtes64@gmail.com"},"directories":{},"maintainers":[{"name":"samtes64","email":"samtes64@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/push-storage-mongo_1.0.0_1768561555452_0.8762712808315309"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-16T11:05:55.333Z","1.0.0":"2026-01-16T11:05:55.591Z","modified":"2026-01-16T11:05:55.834Z"},"maintainers":[{"name":"samtes64","email":"samtes64@gmail.com"}],"description":"MongoDB storage adapter for push notification library","homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-mongo#readme","keywords":["push","notification","storage","mongodb","mongo"],"repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-mongo"},"author":{"name":"Samtes64"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"license":"MIT","readme":"# @allmightypush/push-storage-mongo\n\nMongoDB storage adapter for the push notification library.\n\n## Installation\n\n```bash\nnpm install @allmightypush/push-storage-mongo @allmightypush/push-core mongodb\n```\n\n## Usage\n\n```typescript\nimport { MongoDBStorageAdapter } from '@allmightypush/push-storage-mongo';\nimport { PushCore } from '@allmightypush/push-core';\n\nconst storage = new MongoDBStorageAdapter({\n  uri: 'mongodb://localhost:27017',\n  database: 'push_notifications',\n});\n\nconst pushCore = new PushCore();\npushCore.configure({\n  storageAdapter: storage,\n  // ... other configuration\n});\n```\n\n## Configuration Options\n\n```typescript\ninterface MongoDBStorageOptions {\n  // Connection URI (required)\n  uri: string;\n  \n  // Database name (required)\n  database: string;\n  \n  // MongoDB client options (optional)\n  clientOptions?: MongoClientOptions;\n  \n  // Whether to create indexes automatically (default: true)\n  autoCreateIndexes?: boolean;\n}\n```\n\n## Database Schema\n\nThe adapter creates two collections:\n\n### subscriptions\n\n```javascript\n{\n  id: String (UUID),\n  endpoint: String,\n  keys: {\n    p256dh: String,\n    auth: String\n  },\n  userId: String,\n  createdAt: Date,\n  updatedAt: Date,\n  lastUsedAt: Date,\n  failedCount: Number,\n  status: String, // 'active', 'blocked', or 'expired'\n  expiresAt: Date,\n  metadata: Object\n}\n\n// Indexes\ndb.subscriptions.createIndex({ userId: 1 });\ndb.subscriptions.createIndex({ status: 1 });\ndb.subscriptions.createIndex({ endpoint: 1 }, { unique: true });\n```\n\n### retry_queue\n\n```javascript\n{\n  id: String (UUID),\n  subscriptionId: String,\n  payload: Object,\n  attempt: Number,\n  nextRetryAt: Date,\n  lastError: String,\n  createdAt: Date\n}\n\n// Indexes\ndb.retry_queue.createIndex({ nextRetryAt: 1 });\ndb.retry_queue.createIndex({ subscriptionId: 1 });\n```\n\n## Features\n\n- ✅ Full StorageAdapter interface implementation\n- ✅ Connection pooling built into MongoDB driver\n- ✅ Flexible document storage\n- ✅ Automatic index creation\n- ✅ Unique endpoint constraint\n- ✅ UUID identifiers\n- ✅ Timestamp tracking\n\n## Connection Options\n\nYou can pass MongoDB client options:\n\n```typescript\nconst storage = new MongoDBStorageAdapter({\n  uri: 'mongodb://localhost:27017',\n  database: 'push_notifications',\n  clientOptions: {\n    maxPoolSize: 10,\n    minPoolSize: 2,\n    serverSelectionTimeoutMS: 5000,\n    socketTimeoutMS: 45000,\n  },\n});\n```\n\n## MongoDB Atlas\n\nWorks seamlessly with MongoDB Atlas:\n\n```typescript\nconst storage = new MongoDBStorageAdapter({\n  uri: 'mongodb+srv://username:password@cluster.mongodb.net/?retryWrites=true&w=majority',\n  database: 'push_notifications',\n});\n```\n\n## Replica Sets\n\nSupports MongoDB replica sets:\n\n```typescript\nconst storage = new MongoDBStorageAdapter({\n  uri: 'mongodb://host1:27017,host2:27017,host3:27017/push_notifications?replicaSet=myReplicaSet',\n  database: 'push_notifications',\n});\n```\n\n## Indexes\n\nIndexes are created automatically by default. To create them manually:\n\n```typescript\nconst storage = new MongoDBStorageAdapter({\n  uri: 'mongodb://localhost:27017',\n  database: 'push_notifications',\n  autoCreateIndexes: false,\n});\n\nawait storage.migrate();\n```\n\n## Graceful Shutdown\n\nAlways close the adapter when shutting down:\n\n```typescript\nawait storage.close();\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md","_rev":"1-e033bf15cd31c665b900f4f39547ce0c"}