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

@celerity-sdk/sql-database

v0.8.2

Published

SQL database credentials provider and Knex.js connection factory for the Celerity Node SDK

Downloads

422

Readme

@celerity-sdk/sql-database

SQL database abstraction for the Celerity Node SDK.

Provides credential resolution, connection pooling, and Knex.js query builder instances for cloud-managed SQL databases:

  • AWS: Amazon RDS (PostgreSQL, MySQL)
  • GCP: Google Cloud SQL (planned)
  • Azure: Azure Database (planned)

Features

  • Dual auth modes — password-based and IAM token-based authentication
  • Read replicas — optional separate reader instance with automatic fallback to the writer
  • Deploy-aware pool presets — tuned defaults for serverless functions vs. long-running containers
  • DI integration — parameter decorators for injecting Knex instances into handler classes
  • BYO ORM — inject SqlDatabaseCredentials directly for use with Prisma, Drizzle, or any other ORM

Installation

pnpm add @celerity-sdk/sql-database

Install Knex and a database driver as peer dependencies:

# PostgreSQL
pnpm add knex pg

# MySQL
pnpm add knex mysql2

For IAM authentication on AWS:

pnpm add @aws-sdk/rds-signer

Usage

Basic usage

import { Injectable } from "@celerity-sdk/core";
import { SqlDatabase } from "@celerity-sdk/sql-database";
import type { Knex } from "knex";

@Injectable()
class UserService {
  constructor(@SqlDatabase() private readonly db: Knex) {}

  async findById(id: string) {
    return this.db("users").where("id", id).first();
  }

  async create(name: string, email: string) {
    const [user] = await this.db("users")
      .insert({ name, email })
      .returning("*");
    return user;
  }
}

Writer / reader split

Use @SqlWriter() and @SqlReader() when a read replica is configured:

import { Injectable } from "@celerity-sdk/core";
import { SqlWriter, SqlReader } from "@celerity-sdk/sql-database";
import type { Knex } from "knex";

@Injectable()
class UserService {
  constructor(
    @SqlWriter() private readonly writer: Knex,
    @SqlReader() private readonly reader: Knex,
  ) {}
}

BYO ORM (credentials only)

import { Injectable } from "@celerity-sdk/core";
import { SqlCredentials } from "@celerity-sdk/sql-database";
import type { SqlDatabaseCredentials } from "@celerity-sdk/sql-database";

@Injectable()
class PrismaService {
  constructor(
    @SqlCredentials() private readonly credentials: SqlDatabaseCredentials,
  ) {}

  async getDatabaseUrl(): Promise<string> {
    const auth = await this.credentials.getPasswordAuth();
    return auth.url;
  }
}

Multi-resource support

When multiple SQL databases are linked, use the resource name to disambiguate:

import { Injectable } from "@celerity-sdk/core";
import { SqlWriter } from "@celerity-sdk/sql-database";
import type { Knex } from "knex";

@Injectable()
class AnalyticsService {
  constructor(
    @SqlWriter("analyticsDb") private readonly analytics: Knex,
    @SqlWriter("mainDb") private readonly main: Knex,
  ) {}
}

For a single linked database, the resource name can be omitted and default tokens are used automatically.

Status

This package implements credential resolution, Knex.js connection factory, pool management, and DI integration for AWS RDS (PostgreSQL and MySQL). IAM authentication uses a pluggable TokenProvider interface, with an RdsTokenProvider for AWS. Support for Google Cloud SQL and Azure Database will be added in future releases.

Part of the Celerity Framework

See celerityframework.io for full documentation.