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

@neolith/database

v1.0.39

Published

Prisma database client and schema for Genesis App

Readme

@genesis/database

Prisma database client and schema for the Genesis App. Provides a singleton client optimized for serverless environments with connection pooling.

Installation

npm install @genesis/database

Setup

1. Environment Variables

Create a .env file in the root of your project:

DATABASE_URL="postgresql://user:password@localhost:5432/genesis?schema=public"

For production with connection pooling (e.g., PgBouncer):

DATABASE_URL="postgresql://user:[email protected]:6543/genesis?pgbouncer=true"

2. Generate Prisma Client

npm run db:generate

Migration Commands

Development

Create and apply migrations during development:

# Create a new migration
npm run db:migrate

# Apply migrations without creating new ones
npx prisma migrate dev --name <migration-name>

# Reset the database (destructive!)
npx prisma migrate reset

Production

Deploy migrations to production:

npm run db:migrate:deploy

Database Push (Prototyping)

Push schema changes directly without creating migrations (useful for prototyping):

npm run db:push

Client Usage Examples

Basic Usage

import { prisma } from '@genesis/database';

// Find all users
const users = await prisma.user.findMany();

// Create a user
const user = await prisma.user.create({
  data: {
    email: '[email protected]',
    name: 'John Doe',
  },
});

// Find user by email
const existingUser = await prisma.user.findUnique({
  where: { email: '[email protected]' },
});

With Type Safety

import { prisma, type Prisma } from '@genesis/database';

// Type-safe input
const userData: Prisma.UserCreateInput = {
  email: '[email protected]',
  name: 'John Doe',
  role: 'MEMBER',
};

const user = await prisma.user.create({ data: userData });

Transactions

import { prisma } from '@genesis/database';

const result = await prisma.$transaction(async tx => {
  const user = await tx.user.create({
    data: { email: '[email protected]' },
  });

  // More operations within the same transaction
  // ...

  return user;
});

Health Check

import { healthCheck } from '@genesis/database';

const status = await healthCheck();

if (status.connected) {
  console.log(`Database connected (latency: ${status.latencyMs}ms)`);
} else {
  console.error(`Database connection failed: ${status.error}`);
}

Connection Management

import { connect, disconnect } from '@genesis/database';

// Pre-warm connection (useful for serverless cold starts)
await connect();

// Graceful shutdown
process.on('SIGTERM', async () => {
  await disconnect();
  process.exit(0);
});

Seeding Instructions

1. Create Seed File

Create prisma/seed.ts:

import { prisma } from '../src';

async function main() {
  // Clear existing data (optional)
  await prisma.user.deleteMany();

  // Seed users
  const adminUser = await prisma.user.create({
    data: {
      email: '[email protected]',
      name: 'Admin User',
      role: 'ADMIN',
    },
  });

  console.log('Seeded admin user:', adminUser);
}

main()
  .catch(e => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });

2. Configure package.json

The db:seed script is already configured in package.json:

{
  "prisma": {
    "seed": "ts-node prisma/seed.ts"
  }
}

3. Run Seeding

# Run seed manually
npm run db:seed

# Seed automatically after migrations
npx prisma migrate reset

Prisma Studio

Launch the visual database editor:

npm run db:studio

This opens a web interface at http://localhost:5555 for browsing and editing data.

Serverless Optimization

This package is optimized for serverless environments (Vercel, AWS Lambda, etc.):

  • Connection Pooling: Automatically configured connection limits
  • Singleton Pattern: Prevents connection pool exhaustion during hot reloads
  • Pre-warming: Use connect() to warm up connections before handling requests

Recommended Configuration for Vercel

DATABASE_URL="postgresql://user:pass@host:5432/db?connection_limit=5&pool_timeout=20"

Using Prisma Accelerate

For better serverless performance, consider using Prisma Accelerate:

DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=YOUR_API_KEY"

Development

# Build the package
npm run build

# Generate Prisma client
npm run db:generate

# Open Prisma Studio
npm run db:studio

License

MIT