JSPM

@jrmiranda/adonisjs-polis

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q32004F
  • License ISC

A simple multi tenancy for AdonisJS.

Package Exports

  • @jrmiranda/adonisjs-polis

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 (@jrmiranda/adonisjs-polis) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

AdonisJs Polis

A simple AdonisJs package that allows you to use multi tenancy in your application.

Instalation

  1. Install package:
npm install --save @jrmiranda/adonisjs-polis
  1. Register Polis provider inside start/app.js file:
const providers = [
  ...
  '@jrmiranda/adonisjs-polis/providers/PolisProvider'
  ...
]
  1. Set up the middleware in start/kernel.js file:
const namedMiddleware = {
  ...
  tenant: 'Adonis/Middleware/TenantDetector'
  ...
}

Usage

Add Polis trait to your multi tenant models:

const Model = use('Model')

class User extends Model {
  static boot () {
    super.boot()
    this.addTrait('@provider:TenantAware')
  }
}

And use Polis middleware in the related routes:

Route.group(() => {
  Route.post('/login', 'SessionController.create')
}).middleware(['tenant'])

You can override the default tenant source in config/polis.js file for certain routes by specifying the source of tenant as property of the middleware(header, url_query, url_param, subdomain). For example: middleware(['tenant:subdomain']).

References

This package is based on @brainnit/adonisjs-feud.