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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@allmightypush/push-storage-mongo

v1.0.0

Published

MongoDB storage adapter for push notification library

Downloads

5

Readme

@allmightypush/push-storage-mongo

MongoDB storage adapter for the push notification library.

Installation

npm install @allmightypush/push-storage-mongo @allmightypush/push-core mongodb

Usage

import { MongoDBStorageAdapter } from '@allmightypush/push-storage-mongo';
import { PushCore } from '@allmightypush/push-core';

const storage = new MongoDBStorageAdapter({
  uri: 'mongodb://localhost:27017',
  database: 'push_notifications',
});

const pushCore = new PushCore();
pushCore.configure({
  storageAdapter: storage,
  // ... other configuration
});

Configuration Options

interface MongoDBStorageOptions {
  // Connection URI (required)
  uri: string;
  
  // Database name (required)
  database: string;
  
  // MongoDB client options (optional)
  clientOptions?: MongoClientOptions;
  
  // Whether to create indexes automatically (default: true)
  autoCreateIndexes?: boolean;
}

Database Schema

The adapter creates two collections:

subscriptions

{
  id: String (UUID),
  endpoint: String,
  keys: {
    p256dh: String,
    auth: String
  },
  userId: String,
  createdAt: Date,
  updatedAt: Date,
  lastUsedAt: Date,
  failedCount: Number,
  status: String, // 'active', 'blocked', or 'expired'
  expiresAt: Date,
  metadata: Object
}

// Indexes
db.subscriptions.createIndex({ userId: 1 });
db.subscriptions.createIndex({ status: 1 });
db.subscriptions.createIndex({ endpoint: 1 }, { unique: true });

retry_queue

{
  id: String (UUID),
  subscriptionId: String,
  payload: Object,
  attempt: Number,
  nextRetryAt: Date,
  lastError: String,
  createdAt: Date
}

// Indexes
db.retry_queue.createIndex({ nextRetryAt: 1 });
db.retry_queue.createIndex({ subscriptionId: 1 });

Features

  • ✅ Full StorageAdapter interface implementation
  • ✅ Connection pooling built into MongoDB driver
  • ✅ Flexible document storage
  • ✅ Automatic index creation
  • ✅ Unique endpoint constraint
  • ✅ UUID identifiers
  • ✅ Timestamp tracking

Connection Options

You can pass MongoDB client options:

const storage = new MongoDBStorageAdapter({
  uri: 'mongodb://localhost:27017',
  database: 'push_notifications',
  clientOptions: {
    maxPoolSize: 10,
    minPoolSize: 2,
    serverSelectionTimeoutMS: 5000,
    socketTimeoutMS: 45000,
  },
});

MongoDB Atlas

Works seamlessly with MongoDB Atlas:

const storage = new MongoDBStorageAdapter({
  uri: 'mongodb+srv://username:[email protected]/?retryWrites=true&w=majority',
  database: 'push_notifications',
});

Replica Sets

Supports MongoDB replica sets:

const storage = new MongoDBStorageAdapter({
  uri: 'mongodb://host1:27017,host2:27017,host3:27017/push_notifications?replicaSet=myReplicaSet',
  database: 'push_notifications',
});

Indexes

Indexes are created automatically by default. To create them manually:

const storage = new MongoDBStorageAdapter({
  uri: 'mongodb://localhost:27017',
  database: 'push_notifications',
  autoCreateIndexes: false,
});

await storage.migrate();

Graceful Shutdown

Always close the adapter when shutting down:

await storage.close();

License

MIT