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

@biks2013/asset-database

v1.0.2

Published

PostgreSQL storage for configuration assets with version history

Downloads

9

Readme

@biks2013/asset-database

PostgreSQL storage service for configuration assets with version history and audit logging.

Installation

npm install @biks2013/asset-database

Features

  • 🗄️ PostgreSQL storage with JSONB support
  • 📝 Full version history and audit logging
  • 🔐 SHA256 hash tracking for change detection
  • 🏷️ Category-based organization
  • 🔄 Connection pooling and retry logic
  • ☁️ Azure PostgreSQL support

Usage

import { AssetDatabaseService } from '@biks2013/asset-database';

const service = new AssetDatabaseService({
  connectionString: 'postgresql://user:pass@localhost:5432/mydb',
  ownerCategory: 'application',
  ownerKey: 'my-app',
  ssl: true,
  poolSize: 10,
});

// Ensure database schema exists
await service.ensureSchema();

// Store an asset
await service.storeAsset(
  'app-config',
  JSON.stringify({ version: '1.0.0' }),
  'config',
  'Application configuration'
);

// Retrieve an asset
const asset = await service.getAsset('app-config', 'config');
if (asset) {
  console.log(asset.data.content);
}

// List all assets
const assets = await service.listAssets('config');

// Get asset history
const history = await service.getAssetHistory('app-config');

// Delete an asset
await service.deleteAsset('app-config');

// Close connection pool
await service.close();

Database Schema

The service automatically creates two tables:

asset Table

CREATE TABLE public.asset (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  owner_category VARCHAR(255) NOT NULL,
  asset_category VARCHAR(255) NOT NULL,
  owner_key VARCHAR(255) NOT NULL,
  asset_key VARCHAR(255) NOT NULL,
  description TEXT,
  data JSONB NOT NULL,
  data_hash VARCHAR(64) NOT NULL,
  UNIQUE(owner_key, asset_key)
);

asset_log Table

CREATE TABLE public.asset_log (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  asset_id UUID REFERENCES public.asset(id),
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  owner_category VARCHAR(255) NOT NULL,
  asset_category VARCHAR(255) NOT NULL,
  owner_key VARCHAR(255) NOT NULL,
  asset_key VARCHAR(255) NOT NULL,
  description TEXT,
  data JSONB NOT NULL,
  data_hash VARCHAR(64) NOT NULL
);

API

Constructor Options

interface AssetDatabaseOptions {
  connectionString: string;  // PostgreSQL connection string
  ownerCategory: string;     // Category for this service instance
  ownerKey: string;          // Unique key for this service instance
  ssl?: boolean;             // Enable SSL (default: auto-detect)
  poolSize?: number;         // Connection pool size (default: 10)
}

Methods

ensureSchema(): Promise<void>

Creates the database schema if it doesn't exist.

getAsset(key: string, category?: string): Promise<AssetRecord | null>

Retrieves an asset by key and optional category.

storeAsset(key: string, content: string, category?: string, description?: string): Promise<void>

Stores or updates an asset. Automatically creates history entries.

listAssets(category?: string): Promise<AssetMetadata[]>

Lists all assets, optionally filtered by category.

getAssetHistory(key: string): Promise<AssetHistoryRecord[]>

Retrieves the complete history for an asset.

deleteAsset(key: string): Promise<boolean>

Deletes an asset and its history. Returns true if deleted.

close(): Promise<void>

Closes the database connection pool.

Connection String Format

Standard PostgreSQL:

postgresql://username:password@host:port/database

Azure PostgreSQL:

postgresql://username@servername:[email protected]:5432/database?sslmode=require

License

MIT