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-postgres

v1.0.0

Published

PostgreSQL storage adapter for push notification library

Downloads

36

Readme

@allmightypush/push-storage-postgres

PostgreSQL storage adapter for the push notification library.

Installation

npm install @allmightypush/push-storage-postgres @allmightypush/push-core pg

Usage

import { PostgreSQLStorageAdapter } from '@allmightypush/push-storage-postgres';
import { PushCore } from '@allmightypush/push-core';

const storage = new PostgreSQLStorageAdapter({
  host: 'localhost',
  port: 5432,
  database: 'push_notifications',
  user: 'postgres',
  password: 'password',
});

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

Configuration Options

The adapter accepts all standard node-postgres Pool configuration options:

interface PostgreSQLStorageOptions {
  // Connection options
  host?: string;
  port?: number;
  database?: string;
  user?: string;
  password?: string;
  connectionString?: string;
  
  // Pool options
  max?: number;              // Maximum pool size (default: 10)
  idleTimeoutMillis?: number; // Idle timeout (default: 30000)
  connectionTimeoutMillis?: number; // Connection timeout (default: 0)
  
  // Adapter options
  autoMigrate?: boolean;     // Run migrations automatically (default: true)
}

Database Schema

The adapter creates two tables:

subscriptions

CREATE TABLE subscriptions (
  id UUID PRIMARY KEY,
  endpoint TEXT NOT NULL,
  keys JSONB NOT NULL,
  user_id TEXT,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
  last_used_at TIMESTAMP,
  failed_count INTEGER NOT NULL DEFAULT 0,
  status TEXT NOT NULL CHECK(status IN ('active', 'blocked', 'expired')),
  expires_at TIMESTAMP,
  metadata JSONB
);

CREATE INDEX idx_subscriptions_user_id ON subscriptions(user_id);
CREATE INDEX idx_subscriptions_status ON subscriptions(status);

retry_queue

CREATE TABLE retry_queue (
  id UUID PRIMARY KEY,
  subscription_id UUID NOT NULL,
  payload JSONB NOT NULL,
  attempt INTEGER NOT NULL,
  next_retry_at TIMESTAMP NOT NULL,
  last_error TEXT,
  created_at TIMESTAMP NOT NULL DEFAULT NOW(),
  FOREIGN KEY (subscription_id) REFERENCES subscriptions(id) ON DELETE CASCADE
);

CREATE INDEX idx_retry_queue_next_retry ON retry_queue(next_retry_at);

Features

  • ✅ Full StorageAdapter interface implementation
  • ✅ Connection pooling for performance
  • ✅ JSONB for efficient key and metadata storage
  • ✅ Automatic migrations
  • ✅ Foreign key constraints
  • ✅ Indexed queries for performance
  • ✅ UUID primary keys
  • ✅ Timestamp tracking

Connection String

You can use a connection string instead of individual options:

const storage = new PostgreSQLStorageAdapter({
  connectionString: 'postgresql://user:password@localhost:5432/push_notifications',
});

Environment Variables

The adapter respects standard PostgreSQL environment variables:

  • PGHOST
  • PGPORT
  • PGDATABASE
  • PGUSER
  • PGPASSWORD

Migrations

Migrations run automatically by default. To run them manually:

const storage = new PostgreSQLStorageAdapter({
  connectionString: 'postgresql://...',
  autoMigrate: false,
});

await storage.migrate();

Graceful Shutdown

Always close the adapter when shutting down:

await storage.close();

License

MIT