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

prisma-libs

v1.0.3

Published

Prisma schema and migrations for database management

Readme

Prisma Libs

A modern, type-safe database library built with Prisma ORM. This package provides a clean and intuitive API for database operations with full TypeScript support.

Features

  • 🚀 Latest Prisma Version: Built with Prisma 5.10.0
  • 🔒 Type Safety: Full TypeScript support with generated types
  • 🛠️ Utility Functions: Pre-built CRUD operations for common use cases
  • 🔄 Database Migrations: Easy database schema management
  • 🌱 Seeding: Built-in database seeding for development
  • 📊 Health Checks: Database connection monitoring
  • 🛑 Graceful Shutdown: Proper cleanup on application termination

Installation

npm install prisma-libs

Quick Start

1. Set up your database

Create a .env file in your project root:

DATABASE_URL="postgresql://username:password@localhost:5432/your_database_name"

2. Generate Prisma client

npx prisma generate

3. Push your schema to the database

npx prisma db push

4. Use in your code

import { prisma, userUtils, postUtils, connectDatabase } from 'prisma-libs';

async function main() {
  // Connect to database
  await connectDatabase();

  // Create a user
  const user = await userUtils.createUser('[email protected]', 'John Doe');
  console.log('Created user:', user);

  // Create a post
  const post = await postUtils.createPost(
    'My First Post',
    'This is the content of my first post.',
    user.id,
    true
  );
  console.log('Created post:', post);

  // Find user with posts
  const userWithPosts = await userUtils.findUserById(user.id);
  console.log('User with posts:', userWithPosts);
}

main().catch(console.error);

API Reference

Core Exports

  • prisma: Singleton Prisma client instance
  • PrismaClient: Prisma client class
  • User, Post: Generated TypeScript types

Database Management

import { connectDatabase, disconnectDatabase, healthCheck } from 'prisma-libs';

// Connect to database
await connectDatabase();

// Check database health
const isHealthy = await healthCheck();

// Disconnect from database
await disconnectDatabase();

User Operations

import { userUtils } from 'prisma-libs';

// Create a new user
const user = await userUtils.createUser('[email protected]', 'User Name');

// Find user by email
const user = await userUtils.findUserByEmail('[email protected]');

// Find user by ID (includes posts)
const user = await userUtils.findUserById('user-id');

// Update user
const updatedUser = await userUtils.updateUser('user-id', {
  name: 'New Name',
  email: '[email protected]'
});

// Delete user
await userUtils.deleteUser('user-id');

// Get all users
const users = await userUtils.getAllUsers();

Post Operations

import { postUtils } from 'prisma-libs';

// Create a new post
const post = await postUtils.createPost(
  'Post Title',
  'Post content',
  'author-user-id',
  true // published
);

// Find post by ID (includes author)
const post = await postUtils.findPostById('post-id');

// Find posts by author
const posts = await postUtils.findPostsByAuthor('author-user-id');

// Update post
const updatedPost = await postUtils.updatePost('post-id', {
  title: 'New Title',
  published: true
});

// Delete post
await postUtils.deletePost('post-id');

// Get all posts
const posts = await postUtils.getAllPosts();

// Get only published posts
const publishedPosts = await postUtils.getPublishedPosts();

Graceful Shutdown

import { setupGracefulShutdown } from 'prisma-libs';

// Set up graceful shutdown handlers
setupGracefulShutdown();

Database Schema

The package includes a sample schema with User and Post models:

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  name      String?
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  posts Post[]

  @@map("users")
}

model Post {
  id        String   @id @default(cuid())
  title     String
  content   String?
  published Boolean  @default(false)
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt

  author   User   @relation(fields: [authorId], references: [id], onDelete: Cascade)
  authorId String

  @@map("posts")
}

Development

Prerequisites

  • Node.js 18 or higher
  • PostgreSQL database
  • npm or yarn

Setup

  1. Clone the repository
  2. Install dependencies: npm install
  3. Copy env.example to .env and configure your database URL
  4. Generate Prisma client: npm run generate
  5. Push schema to database: npm run db:push
  6. Seed database: npm run db:seed

Available Scripts

  • npm run build - Build the TypeScript code
  • npm run dev - Watch mode for development
  • npm run generate - Generate Prisma client
  • npm run db:push - Push schema changes to database
  • npm run db:migrate - Create and apply migrations
  • npm run db:studio - Open Prisma Studio
  • npm run db:seed - Seed the database with sample data

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and questions, please open an issue on GitHub. # prisma-libs