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

@api-buddy/prisma

v3.0.0

Published

Prisma database utilities for API Buddy

Downloads

15

Readme

@api-buddy/prisma

A powerful Prisma extension for API Buddy that provides type-safe database access, automatic CRUD API generation, and enhanced developer experience for Next.js applications.

Installation

pnpm add @api-buddy/prisma @prisma/client

Features

  • 🔄 Automatic CRUD API Generation - Generate RESTful API routes from your Prisma schema
  • 🛡️ Type-Safe Database Access - Full TypeScript support with zero-config type safety
  • 📊 Built-in Logging - Comprehensive logging for all database operations
  • 🚀 Next.js Integration - Seamless integration with Next.js API routes and Server Components
  • Performance Optimized - Built with performance and developer experience in mind

Basic Usage

1. Initialize the Prisma Service

import { PrismaService } from '@api-buddy/prisma';

// Initialize with your Prisma schema
const prisma = new PrismaService({
  log: ['query', 'info', 'warn', 'error'],
});

// Use like regular Prisma Client
const users = await prisma.user.findMany();

2. Generate CRUD APIs (CLI)

Automatically generate RESTful API routes for your Prisma models:

npx @api-buddy/prisma generate:routes --output src/app/api

This will create RESTful API endpoints for all your Prisma models in the specified directory.

3. Use in Next.js API Routes

// app/api/users/route.ts
import { prisma } from '@/lib/prisma';
import { NextResponse } from 'next/server';

export async function GET() {
  const users = await prisma.user.findMany();
  return NextResponse.json(users);
}

export async function POST(request: Request) {
  const data = await request.json();
  const user = await prisma.user.create({ data });
  return NextResponse.json(user, { status: 201 });
}

Advanced Usage

Generate Routes for Specific Models

npx @api-buddy/prisma generate:routes --models User,Post --output src/app/api

Exclude Models from Generation

npx @api-buddy/prisma generate:routes --exclude User,Session --output src/app/api

Add Authentication to Routes

npx @api-buddy/prisma generate:routes --auth --output src/app/api

API Reference

PrismaService

Extends the standard PrismaClient with additional features:

const prisma = new PrismaService({
  // Standard Prisma options
  log: ['query', 'info', 'warn', 'error'],
  
  // Custom logger (optional)
  logger: {
    info: (message) => console.log(`[INFO] ${message}`),
    error: (message, error) => console.error(`[ERROR] ${message}`, error)
  }
});

// Generate CRUD routes programmatically
await prisma.generateCRUDRoutes({
  outputDir: 'src/app/api',
  models: ['User', 'Post'],
  exclude: ['Session', 'Account'],
  auth: {
    required: true,
    userIdField: 'id'
  }
});

Configuration

CLI Options

Usage: api-buddy-prisma generate:routes [options]

Generate CRUD routes from your Prisma schema

Options:
  -o, --output <dir>  Output directory for generated routes (default: "src/app/api")
  --models <models>    Specific models to generate routes for (comma-separated)
  --exclude <models>   Models to exclude from route generation (comma-separated)
  --auth               Add authentication middleware to routes
  -h, --help           Display help for command

License

MIT