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

@effectify/prisma

v0.1.2

Published

A powerful Prisma generator that creates **Effect** services and layers from your Prisma schema, enabling seamless integration of Prisma with the Effect ecosystem.

Readme

@effectify/prisma

A powerful Prisma generator that creates Effect services and layers from your Prisma schema, enabling seamless integration of Prisma with the Effect ecosystem.

🚀 Features

  • Effect-Native Services: Auto-generated Effect services for all your Prisma models.
  • Dependency Injection: Ready-to-use Layers for easy testing and production setup.
  • Type-Safe Error Handling: All Prisma errors are mapped to typed Effect errors (e.g., PrismaUniqueConstraintError).
  • Transaction Support: Native Effect integration for Prisma transactions.
  • Schema Validation: Integration with @effect/schema for runtime validation.

📦 Installation

pnpm add -D @effectify/prisma prisma-effect-kysely
pnpm add effect @prisma/client

🛠️ Configuration

Add the generator to your schema.prisma file:

generator client {
  provider = "prisma-client-js"
}

generator effect_schemas {
  provider = "prisma-effect-kysely"
  output   = "./generated/effect/schemas"
}

generator effect {
  provider = "effect-prisma"
  output   = "./generated/effect"
}

datasource db {
  provider = "sqlite" // or postgresql, mysql, etc.
  url      = env("DATABASE_URL")
}

⚙️ Usage

1. Generate the Code

Run the Prisma generator to create your Effect services:

pnpm prisma generate

2. Use the Generated Services

The generator creates a Prisma service for transactions and raw queries, and Model classes that you can use to create repositories.

import { Effect, Layer } from "effect";
import { Prisma, UserModel } from "./generated/effect/index.js";
import * as PrismaRepository from "./generated/effect/prisma-repository.js";

// Define a program using the generated Prisma service
const program = Effect.gen(function* () {
  // Create a repository for the User model
  const userRepo = yield* PrismaRepository.make(UserModel, {
    modelName: "user",
    spanPrefix: "User",
  });

  // Create a new user
  const newUser = yield* userRepo.create({
    data: {
      email: "[email protected]",
      name: "Effect User",
    },
  });

  // Find the user
  const user = yield* userRepo.findUnique({
    where: { id: newUser.id },
  });

  return user;
});

// Provide the Prisma layer
const MainLayer = Prisma.layer({
  // Prisma Client options
  log: ["query", "info", "warn", "error"],
});

// Run the program
Effect.runPromise(program.pipe(Effect.provide(MainLayer)));

🧪 Testing

The generated layers make testing easy by allowing you to provide alternative implementations or test databases.

import { it } from "@effect/vitest";
import { Effect } from "effect";
import { Prisma, UserModel } from "./generated/effect/index.js";
import * as PrismaRepository from "./generated/effect/prisma-repository.js";

it.effect("should create a user", () =>
  Effect.gen(function* () {
    const userRepo = yield* PrismaRepository.make(UserModel, {
      modelName: "user",
      spanPrefix: "User",
    });

    const user = yield* userRepo.create({
      data: { email: "[email protected]" },
    });

    expect(user.email).toBe("[email protected]");
  }).pipe(
    Effect.provide(Prisma.layer()) // In tests, you might want to use a specific test DB url
  )
);

⚠️ Error Handling

All Prisma errors are mapped to specific tagged errors in Effect, allowing you to handle them precisely.

import { Effect } from "effect";
import { Prisma, UserModel } from "./generated/effect/index.js";
import * as PrismaRepository from "./generated/effect/prisma-repository.js";

const createUser = (email: string) =>
  Effect.gen(function* () {
    const userRepo = yield* PrismaRepository.make(UserModel, {
      modelName: "user",
      spanPrefix: "User",
    });

    return yield* userRepo.create({
      data: { email },
    });
  }).pipe(
    Effect.catchTag("PrismaUniqueConstraintError", (error) =>
      Effect.logError(`User with email ${email} already exists`)
    )
  );

📝 License

MIT