adonis-prisma
adonis-prisma copied to clipboard
Incompatible with the new Adonis JS 6 ?
$ npm i @wahyubucil/adonis-prisma
returns:
npm ERR! code ERESOLVE npm ERR! ERESOLVE unable to resolve dependency tree npm ERR! npm ERR! While resolving: [email protected] npm ERR! Found: @adonisjs/[email protected] 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/[email protected] 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/[email protected] npm ERR! node_modules/@wahyubucil/adonis-prisma npm ERR! @wahyubucil/adonis-prisma@"*" from the root project
any updates?
I think it will take a long time if there is an update, because adonisjs v5 to v6 is a big difference Looking forward !
I'm working on an adapter for Adonis 6. I'll will post soon the link of the Github page.
Is there any update for Adonis 6 ?
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('[email protected]', '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.
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 optionThen
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
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 Thennode 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
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('[email protected]', '123456')
to verify user credentials. thenawait auth.use('web').login(user)
to login the user. You can read more here : Adonis DocsIn 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/seeders
directory
node ace prisma:seed
to seed all the files
Hey guys, I have written docs and made public the GitHub repo of the package. Here is the link : link to repo
Appreciate you making the package. Are you using it in production yet? Also, do you want contributors @ArthurFranckPat ?