JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q20473F
  • License MIT

Blitz plugin for prisma-multi-tenant

Package Exports

  • @prisma-tenancy/blitz
  • @prisma-tenancy/blitz/build/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@prisma-tenancy/blitz) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Blitz plugin for Prisma-multi-tenant 🧭

Version Documentation Maintenance License: MIT Twitter: Errorname_

🧭 Add multi-tenancy to your Blitz application

Installation

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

Usage

⚠️ First, make sure you followed the Prisma-multi-tenant Getting Started Guide. ⚠️

First, add the multiTenantMiddleware to your blitz.config.js file:

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
    }),
  ],
}

Note: Restart the server after modifying blitz.config.js

Then, in your queries and mutations, access the tenant from the context:

export default async function getProjects(args, ctx) {
  const projects = await ctx.db.project.findMany(args)

  return projects
}

Example

Check out an example application using Blitz and the multi-tenant plugin here.

Documentation

Read more on how prisma-multi-tenant can help you achieve multi-tenancy for your apps:

Author

👤 Thibaud Courtoison

🤝 Contributors

Contributions, issues, and feature requests are welcome! 🙌

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Thibaud Courtoison.

This project is MIT licensed.