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

@aust-wide-tax/db-client

v4.1.1

Published

Database client for Austware microservices

Downloads

84

Readme

@aust-wide-tax/db-client

A PostgreSQL database client for microservices with automatic schema validation and type safety.

Installation

npm install @aust-wide-tax/db-client

Configuration

Set the following environment variables in your deployment environment:

AUSTWIDE_DB_HOST=your_host
AUSTWIDE_DB_PORT=5432
AUSTWIDE_DB_NAME=your_database
AUSTWIDE_DB_USER=your_user
AUSTWIDE_DB_PASSWORD=your_password
AUSTWIDE_DB_SSL=true  # Optional, for SSL connections

Usage

Basic Usage

import Database from '@aust-wide-tax/db-client';

// Create a new database instance
const db = new Database();

// Use the database
const users = await db.users.find({ role: 'admin' });

Table Operations

// Insert a record
const newUser = await db.users.insert({
  name: 'John Doe',
  email: '[email protected]'
});

// Find records
const users = await db.users.find({ 
  email: '[email protected]' 
});

// Update records
const updatedUsers = await db.users.update(
  { id: 1 },  // criteria
  { name: 'Jane Doe' }  // new data
);

// Delete a record
const deletedUser = await db.users.delete(1);

Connection Management

The client uses connection pooling for better performance. Here's how to properly manage connections in your microservice:

// database.ts
import Database from '@aust-wide-tax/db-client';

// Create a single instance for your service
export const db = new Database();

// userService.ts
export class UserService {
    constructor(private db: Database) {}

    async getUser(id: number) {
        return await this.db.users.find({ id });
    }
}

// index.ts (main service file)
import { db } from './database';
import { UserService } from './userService';

const userService = new UserService(db);

// Handle graceful shutdown
process.on('SIGTERM', async () => {
    console.log('Shutting down...');
    await db.shutdown();
    process.exit(0);
});

Best Practices

  1. Create a Single Instance:

    // ✅ GOOD: Create one instance and reuse it
    const db = new Database();
  2. Don't Shutdown After Every Operation:

    // ❌ BAD: Don't do this
    async function getUser(id: number) {
        const db = new Database();
        const user = await db.users.find({ id });
        await db.shutdown();  // Don't do this!
        return user;
    }
  3. Handle Service Shutdown:

    // ✅ GOOD: Shutdown only when the service is stopping
    process.on('SIGTERM', async () => {
        await db.shutdown();
    });

Features

  • Automatic schema validation
  • Type safety with TypeScript
  • Dynamic table access
  • Connection pooling
  • SQL injection protection
  • Support for complex queries
  • Graceful connection management

License

MIT