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

ts-firebird

v1.2.0

Published

Promisify node-firebird

Downloads

13

Readme

ts-firebird

A TypeScript wrapper for node-firebird with Promise support and connection pool monitoring.

Features

  • 🔄 Promise-based API (async/await)
  • 📊 Connection pool with monitoring
  • 🔍 Track active transactions and connections
  • 🛡️ Automatic cleanup with rollbackAllTransactions()
  • 📝 Full TypeScript support
  • ✅ Comprehensive test coverage

Installation

npm install ts-firebird

Quick Start

Basic Usage

import { FirebirdDatabase } from 'ts-firebird';

const db = new FirebirdDatabase();
await db.attach({
    host: 'localhost',
    port: 3050,
    database: '/path/to/database.fdb',
    user: 'SYSDBA',
    password: 'masterkey'
});

// Execute query
const result = await db.query('SELECT * FROM USERS WHERE ID = ?', [1]);

// With transaction
const tx = await db.transaction();
await tx.execute('UPDATE USERS SET NAME = ? WHERE ID = ?', ['John', 1]);
await tx.commit();

db.detach();

Connection Pool

import { FirebirdPool } from 'ts-firebird';

const pool = new FirebirdPool(5, {
    host: 'localhost',
    port: 3050,
    database: '/path/to/database.fdb',
    user: 'SYSDBA',
    password: 'masterkey'
});

// Get database from pool
const db = await pool.getDatabase();
const tx = await db.transaction();
await tx.query('SELECT * FROM USERS', []);
await tx.commit(true); // auto detach

// Get statistics
console.log('Active transactions:', pool.getActiveTransactionsCount());
console.log('Active connections:', pool.getActiveConnectionsCount());
console.log('Available connections:', pool.getAvailableConnectionsCount());
console.log('Max connections:', pool.getMaxConnections());

// Cleanup hanging transactions
await pool.rollbackAllTransactions();

pool.destroy();

API Reference

FirebirdPool

Constructor

new FirebirdPool(max: number, options: Options)

Methods

  • getDatabase(): Promise<FirebirdDatabase> - Get database connection from pool
  • getTransaction(isolation?: Isolation): Promise<FirebirdTransaction> - Get transaction directly
  • getActiveTransactionsCount(): number - Number of uncommitted transactions
  • getActiveConnectionsCount(): number - Number of active connections
  • getAvailableConnectionsCount(): number - Number of available connection slots
  • getMaxConnections(): number - Maximum pool size
  • getActiveTransactions(): FirebirdTransaction[] - List of active transactions
  • rollbackAllTransactions(): Promise<void> - Rollback all hanging transactions
  • destroy(): void - Destroy pool and close all connections

FirebirdDatabase

Methods

  • attach(options: Options): Promise<FirebirdDatabase>
  • create(options: Options): Promise<FirebirdDatabase>
  • attachOrCreate(options: Options): Promise<FirebirdDatabase>
  • query(query: string, params: any[], detach?: boolean): Promise<any[]>
  • execute(query: string, params: any[], detach?: boolean): Promise<any[]>
  • transaction(isolation?: Isolation): Promise<FirebirdTransaction>
  • detach(): void

FirebirdTransaction

Methods

  • query(query: string, params: any[], autoCommit?: boolean): Promise<any[]>
  • execute(query: string, params: any[], autoCommit?: boolean): Promise<any[]>
  • commit(detach?: boolean): Promise<void>
  • rollback(detach?: boolean): Promise<void>
  • detach(): void

Monitoring Hanging Connections

One of the key features is the ability to monitor and cleanup hanging transactions:

const pool = new FirebirdPool(5, options);

// Check for hanging transactions
setInterval(() => {
    const activeCount = pool.getActiveTransactionsCount();
    const activeConns = pool.getActiveConnectionsCount();

    if (activeCount > 0) {
        console.warn(`Warning: ${activeCount} uncommitted transactions!`);
        console.warn(`Active connections: ${activeConns}/${pool.getMaxConnections()}`);

        // Optionally rollback all
        // await pool.rollbackAllTransactions();
    }
}, 60000); // Check every minute

Isolation Levels

import {
    ISOLATION_READ_UNCOMMITTED,
    ISOLATION_READ_COMMITTED,
    ISOLATION_REPEATABLE_READ,
    ISOLATION_SERIALIZABLE
} from 'ts-firebird';

const tx = await db.transaction(ISOLATION_READ_COMMITTED);

Testing

npm test

License

MIT

Credits

Built on top of node-firebird