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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@galadrim/adonis-prisma

v0.0.15

Published

Prisma provider for AdonisJS

Downloads

21

Readme

Adonis JS Prisma Adapter

This is an AdonisJS provider for Prisma ORM.

Getting Started

Installation

node ace add @galadrim/adonis-prisma

This command will scaffold the config files, providers and create a prisma folder with prisma.schema file.

Post Installation

After installation, you should run the proper commands to migrate your schema and/or generate the Prisma Client :

  npx prisma generate

Usage

You have two options to use the Prisma Client.

  • By destructuring HttpContextobject :
//route.ts

router
  .get('/', async function ({ prisma }: HttpContext) {
    ...
    const posts = await prisma.post.findMany())
    ...
  })
  • By importing prisma from @galadrim/adonis-prisma/services :
import prisma from '@galadrim/adonis-prisma/services'

Authentication

First, you should configure the prisma service inside config/prisma.ts file.

export const prismaConfig = defineConfig({
  user: {
    hash: () => hash.use(),
    passwordColumnName: 'password',
    uids: ['email', 'id'],
  },
})

The user key is the model name you want to use for authentication. Then you can configure it the same way you would with the withAuthFinder mixin from @adonisjs/lucid.

  • hash: The hash function to use for hashing the password.
  • passwordColumnName: The name of the column to store the password.
  • uids: The list of columns to use for authentication.

Then,you should install the @adonisjs/auth and configure it with Session as Auth Guard. Then, you should replace the provider key in the config/auth.ts file with this:

//config/auth.ts
  import { sessionUserProvider } from '@galadrim/adonis-prisma'
  import { configProvider } from '@adonisjs/core'
  ... other imports

  ...
       user: sessionGuard({
          provider: sessionUserProvider('user'),
          useRememberMeTokens: false,
        }),

After that, you can use the provided methods to facilitate the authentication flow. Like, the @adonisjs/lucid, there is two methods for authentication

  • To verify user credentials, you can use this method : const user = await prisma.user.verifyCredentials('email', 'password')

  • The password is automatically hashed via the @adonisjs/hash package when creating or updating an user, based on the default hasher configured inside the config/hash.ts.

NB: For now the package doesn't support the refreshToken method. I'm working on it.

Database Seeding

You can define seeders for your DB with the following command :

node ace make:seeder <name_of_the_seeder>

It will create a seeder file inside the prisma/seeders directory.

Then, to seed the database you should run : node ace prisma:seed command. NB: This command runs all the seeders files inside prisma/seeders directory.

Before leaving...

Credit to ArthurFranckPat, I used a lot of his work as a base for this package, mainly for the seeder (and this doc)