Blitz plugin for prisma-multi-tenant
npm install @prisma-multi-tenant/blitz> đ§ Add multi-tenancy to your Blitz application
``sh
npm i -g prisma-multi-tenant # CLI for tenant management
npm i @prisma-multi-tenant/blitz # Blitz plugin
prisma-multi-tenant init # Init multi-tenancy in your Blitz project
`
â ď¸ First, make sure you followed the Prisma-multi-tenant Getting Started Guide. â ď¸
First, add the multiTenantMiddleware to your blitz.config.js file:
`js
const { multiTenantMiddleware } = require('@prisma-multi-tenant/blitz')
module.exports = {
// ...
middleware: [
multiTenantMiddleware((req, res) => {
// The name can come from anywhere (headers, token, ...)
return 'dev' // or 'my_tenant_A' or anything
}),
],
}
`
Then, in your queries and mutations, access the tenant from the context:
`js
export default async function getProjects(args, ctx) {
const projects = await ctx.db.project.findMany(args)
return projects
}
`
Check out an example application using Blitz and the multi-tenant plugin here.
Read more on how prisma-multi-tenant` can help you achieve multi-tenancy for your apps:
- ⨠Getting Started â¨
- Complete documentation
- How to integrate with:
- Express
- Apollo
- Nexus
- Blitz
- Redwood
- Bison (TODO)
- Examples
- Basic (JS)
- Basic (TS)
- Express
- Apollo
- Nexus
- Blitz
- Redwood
- Bison (TODO)
- Issues with Vercel
- Contributing guide
đ¤ Thibaud Courtoison
- Twitter: @Errorname\_
- Github: @Errorname
- Prisma's Slack: @Errorname
Contributions, issues, and feature requests are welcome! đ
Feel free to check issues page.
Give a âď¸ if this project helped you!
Copyright Š 2020 Thibaud Courtoison.
This project is MIT licensed.