{"_id":"@allmightypush/push-storage-postgres","name":"@allmightypush/push-storage-postgres","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@allmightypush/push-storage-postgres","version":"1.0.0","description":"PostgreSQL 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","postgresql","postgres"],"author":{"name":"Samtes64"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-postgres"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-postgres#readme","dependencies":{"@allmightypush/push-core":"^1.0.0","pg":"^8.11.3"},"devDependencies":{"@types/pg":"^8.10.9"},"engines":{"node":">=16.0.0"},"_id":"@allmightypush/push-storage-postgres@1.0.0","gitHead":"8d7b012f519f95515344d9b5c96d4ba42039046b","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-SJ2lMZtKipFLjCwhMZSLHBWBGFhT0V6saq7PB1wkSC+o+2GC1b7C9nn89c3tkDx8GG59ivuFpEi85siCk0BCxA==","shasum":"c97220b8569c843e48fa2387057d9b07b0e00351","tarball":"https://registry.npmjs.org/@allmightypush/push-storage-postgres/-/push-storage-postgres-1.0.0.tgz","fileCount":8,"unpackedSize":44821,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDW4WCMWvL4SAi3clMoJYy4gPZt98jaSHMv2km5wzxdTgIgT/5eH0Vq6037+gKllttiy6sQCCx6Xvg+GLKta9se15w="}]},"_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-postgres_1.0.0_1768561530874_0.475015311360828"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-16T11:05:30.781Z","1.0.0":"2026-01-16T11:05:31.018Z","modified":"2026-01-16T11:05:31.234Z"},"maintainers":[{"name":"samtes64","email":"samtes64@gmail.com"}],"description":"PostgreSQL storage adapter for push notification library","homepage":"https://github.com/Samtes64/all-mighty-push/tree/main/packages/push-storage-postgres#readme","keywords":["push","notification","storage","postgresql","postgres"],"repository":{"type":"git","url":"git+https://github.com/Samtes64/all-mighty-push.git","directory":"packages/push-storage-postgres"},"author":{"name":"Samtes64"},"bugs":{"url":"https://github.com/Samtes64/all-mighty-push/issues"},"license":"MIT","readme":"# @allmightypush/push-storage-postgres\n\nPostgreSQL storage adapter for the push notification library.\n\n## Installation\n\n```bash\nnpm install @allmightypush/push-storage-postgres @allmightypush/push-core pg\n```\n\n## Usage\n\n```typescript\nimport { PostgreSQLStorageAdapter } from '@allmightypush/push-storage-postgres';\nimport { PushCore } from '@allmightypush/push-core';\n\nconst storage = new PostgreSQLStorageAdapter({\n  host: 'localhost',\n  port: 5432,\n  database: 'push_notifications',\n  user: 'postgres',\n  password: 'password',\n});\n\nconst pushCore = new PushCore();\npushCore.configure({\n  storageAdapter: storage,\n  // ... other configuration\n});\n```\n\n## Configuration Options\n\nThe adapter accepts all standard [node-postgres Pool configuration options](https://node-postgres.com/apis/pool):\n\n```typescript\ninterface PostgreSQLStorageOptions {\n  // Connection options\n  host?: string;\n  port?: number;\n  database?: string;\n  user?: string;\n  password?: string;\n  connectionString?: string;\n  \n  // Pool options\n  max?: number;              // Maximum pool size (default: 10)\n  idleTimeoutMillis?: number; // Idle timeout (default: 30000)\n  connectionTimeoutMillis?: number; // Connection timeout (default: 0)\n  \n  // Adapter options\n  autoMigrate?: boolean;     // Run migrations automatically (default: true)\n}\n```\n\n## Database Schema\n\nThe adapter creates two tables:\n\n### subscriptions\n\n```sql\nCREATE TABLE subscriptions (\n  id UUID PRIMARY KEY,\n  endpoint TEXT NOT NULL,\n  keys JSONB NOT NULL,\n  user_id TEXT,\n  created_at TIMESTAMP NOT NULL DEFAULT NOW(),\n  updated_at TIMESTAMP NOT NULL DEFAULT NOW(),\n  last_used_at TIMESTAMP,\n  failed_count INTEGER NOT NULL DEFAULT 0,\n  status TEXT NOT NULL CHECK(status IN ('active', 'blocked', 'expired')),\n  expires_at TIMESTAMP,\n  metadata JSONB\n);\n\nCREATE INDEX idx_subscriptions_user_id ON subscriptions(user_id);\nCREATE INDEX idx_subscriptions_status ON subscriptions(status);\n```\n\n### retry_queue\n\n```sql\nCREATE TABLE retry_queue (\n  id UUID PRIMARY KEY,\n  subscription_id UUID NOT NULL,\n  payload JSONB NOT NULL,\n  attempt INTEGER NOT NULL,\n  next_retry_at TIMESTAMP NOT NULL,\n  last_error TEXT,\n  created_at TIMESTAMP NOT NULL DEFAULT NOW(),\n  FOREIGN KEY (subscription_id) REFERENCES subscriptions(id) ON DELETE CASCADE\n);\n\nCREATE INDEX idx_retry_queue_next_retry ON retry_queue(next_retry_at);\n```\n\n## Features\n\n- ✅ Full StorageAdapter interface implementation\n- ✅ Connection pooling for performance\n- ✅ JSONB for efficient key and metadata storage\n- ✅ Automatic migrations\n- ✅ Foreign key constraints\n- ✅ Indexed queries for performance\n- ✅ UUID primary keys\n- ✅ Timestamp tracking\n\n## Connection String\n\nYou can use a connection string instead of individual options:\n\n```typescript\nconst storage = new PostgreSQLStorageAdapter({\n  connectionString: 'postgresql://user:password@localhost:5432/push_notifications',\n});\n```\n\n## Environment Variables\n\nThe adapter respects standard PostgreSQL environment variables:\n\n- `PGHOST`\n- `PGPORT`\n- `PGDATABASE`\n- `PGUSER`\n- `PGPASSWORD`\n\n## Migrations\n\nMigrations run automatically by default. To run them manually:\n\n```typescript\nconst storage = new PostgreSQLStorageAdapter({\n  connectionString: 'postgresql://...',\n  autoMigrate: 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-f4d21f033e2f2fa23cf998d1689738d4"}