wahyubucil / adonis-prisma

Prisma Provider for AdonisJS
MIT License
79 stars 9 forks source link

Incompatible with the new Adonis JS 6 ? #8

Open costearnaud opened 5 months ago

costearnaud commented 5 months ago

$ npm i @wahyubucil/adonis-prisma

returns:

npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: adonis6@0.0.0 npm ERR! Found: @adonisjs/core@6.2.2 npm ERR! node_modules/@adonisjs/core npm ERR! @adonisjs/core@"^6.2.1" from the root project npm ERR! peer @adonisjs/core@"^6.2.0" from @adonisjs/auth@9.0.3 npm ERR! node_modules/@adonisjs/auth npm ERR! @adonisjs/auth@"^9.0.2" from the root project npm ERR! 4 more (@adonisjs/lucid, @adonisjs/session, @adonisjs/redis, @japa/plugin-adonisjs) npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer @adonisjs/core@"^5.9.0" from @wahyubucil/adonis-prisma@1.0.1 npm ERR! node_modules/@wahyubucil/adonis-prisma npm ERR! @wahyubucil/adonis-prisma@"*" from the root project

mohamadlounnas commented 4 months ago

any updates?

truongbo17 commented 3 months ago

I think it will take a long time if there is an update, because adonisjs v5 to v6 is a big difference Looking forward !

ArthurFranckPat commented 2 months ago

I'm working on an adapter for Adonis 6. I'll will post soon the link of the Github page.

Tommymiza commented 1 month ago

image Is there any update for Adonis 6 ?

ArthurFranckPat commented 1 month ago

image Is there any update for Adonis 6 ?

Yes, I have to write proper docs and fix some types issues with prisma client but the package can be used (in dev mode) For those who want to test, here is the link of the package : NPM module page

After installation, run these commands:

node ace configure @adonisjs/auth ... choose Session as option, if not already done.

Then node ace configure @arthurfranckpat/adonis-prisma It'ill scaffold the config files and providers.

Next, you should run : npx prisma generate (to generate the prisma client)

Then, you have two options to use the prisma client :

Or

There is also an api dedicated to authentication that follow the same api as the official documentation from adonis core team. You have to modify the config/auth.ts file in that way :

import { configProvider } from '@adonisjs/core'

...
      provider: configProvider.create(async () => {
        const { SessionPrismaUserProvider } = await import(
          '@arthurfranckpat/adonis-prisma/prisma_user_provider'
        )
        return new SessionPrismaUserProvider()
      })

As I mentioned, the authentication flow, follows the same API as the official docs, so you can use const user = await prisma.user.verifyCredentials('C9Ykz@example.com', '123456') to verify user credentials. then await auth.use('web').login(user) to login the user. You can read more here : Adonis Docs

In waiting of proper docs, I hope you'll find these explanations useful

PS : The package needs some tweaks, especially on prisma client type generation when adding new models

Have fun

Excuse for my approximative English, I'am French native language speaker.

SOG-web commented 1 month ago

image Is there any update for Adonis 6 ?

Yes, I'll make a post below tomorrow. I have to write proper docs and fix some types issues with prisma client. For those who want to test, here is the link of the package : https://www.npmjs.com/package/@arthurfranckpat/adonis-prisma

After installation, run these commands:

node ace configure @adonisjs/auth ... choose Session as option

Then node ace configure @arthurfranckpat/adonis-prisma It'ill scaffold the config files and providers.

Next, you should run : npx prisma generate (to generate the prisma client)

Then, you have two options to use the prisma client :

  • Calling the IoC container with : const prisma = await app.container.make('prisma:db')

Or

  • the prisma client is bound to the HttpContext. You can grab in a controller like the request or response object

There is also an api dedicated to authenticated based on the official documentation from adonis core team. I've to find time to write the docs.

PS : The package needs some tweaks, especially on prisma client type generation when adding new models

Have fun

What if am using both session and API key

Am working on a project that has both inertia and API layer for mobile app

ArthurFranckPat commented 1 month ago

image Is there any update for Adonis 6 ?

Yes, I'll make a post below tomorrow. I have to write proper docs and fix some types issues with prisma client. For those who want to test, here is the link of the package : https://www.npmjs.com/package/@arthurfranckpat/adonis-prisma After installation, run these commands: node ace configure @adonisjs/auth ... choose Session as option Then node ace configure @arthurfranckpat/adonis-prisma It'ill scaffold the config files and providers. Next, you should run : npx prisma generate (to generate the prisma client) Then, you have two options to use the prisma client :

  • Calling the IoC container with : const prisma = await app.container.make('prisma:db')

Or

  • the prisma client is bound to the HttpContext. You can grab in a controller like the request or response object

There is also an api dedicated to authenticated based on the official documentation from adonis core team. I've to find time to write the docs. PS : The package needs some tweaks, especially on prisma client type generation when adding new models Have fun

What if am using both session and API key

Am working on a project that has both inertia and API layer for mobile app

I only implemented the Session layer. Feel free to try with API

ArthurFranckPat commented 1 month ago

image Is there any update for Adonis 6 ?

Yes, I have to write proper docs and fix some types issues with prisma client but the package can be used (in dev mode) For those who want to test, here is the link of the package : NPM module page

After installation, run these commands:

node ace configure @adonisjs/auth ... choose Session as option, if not already done.

Then node ace configure @arthurfranckpat/adonis-prisma It'ill scaffold the config files and providers.

Next, you should run : npx prisma generate (to generate the prisma client)

Then, you have two options to use the prisma client :

  • Calling the IoC container with : const prisma = await app.container.make('prisma:db')

Or

  • the prisma client is bound to the HttpContext. You can grab in a controller like the request or response object

There is also an api dedicated to authentication that follow the same api as the official documentation from adonis core team. You have to modify the config/auth.ts file in that way :

import { configProvider } from '@adonisjs/core'

...
      provider: configProvider.create(async () => {
        const { SessionPrismaUserProvider } = await import(
          '@arthurfranckpat/adonis-prisma/prisma_user_provider'
        )
        return new SessionPrismaUserProvider()
      })

As I mentioned, the authentication flow, follows the same API as the official docs, so you can use const user = await prisma.user.verifyCredentials('C9Ykz@example.com', '123456') to verify user credentials. then await auth.use('web').login(user) to login the user. You can read more here : Adonis Docs

In waiting of proper docs, I hope you'll find these explanations useful

PS : The package needs some tweaks, especially on prisma client type generation when adding new models

Have fun

Excuse for my approximative English, I'am French native language speaker.

You have also two command for seeding : node ace prisma:make-seeder to create a seeder file in the prisma/seedersdirectory node ace prisma:seed to seed all the files

ArthurFranckPat commented 1 month ago

Hey guys, I have written docs and made public the GitHub repo of the package. Here is the link : link to repo

futuregerald commented 1 month ago

Appreciate you making the package. Are you using it in production yet? Also, do you want contributors @ArthurFranckPat ?