4.43.0 • Published 5 years ago

lec-multitenant-api v4.43.0

Weekly downloads
-
License
ISC
Repository
github
Last release
5 years ago

LECMultitenant

Run migrations

### Typeorm
DEV_URL=postgres://postgres:postgres@127.0.0.1:5432/postgres
TEST_URL=postgres://postgres:postgres@127.0.0.1:5432/postgres-test
ORM_SCHEMA=experimental
ORM_ENTITIES=src/models/*.ts
ORM_MIGRATIONS=src/migrations/*.ts
ORM_MIGRATIONS_DIR=src/migrations

Authorization API

For define the different authorization actions (capacities) and context you should use the authorization API.

POST /authorization/actions

{
  "context": {
    "key": string,
    "label": string,
    "order": array of array with actions keys for render in the frontend
  },
  "actions": array of Actions (see below)
}
// Action representation
{
  "key": string,
  "label": string,
  "dependencies": array with keys of actions dependencies
}

Body post example for register a context and their actions:

{
  "context": {
    "key": "REPORTS",
    "label": "Reports",
    "order": [
      "REPORTS_VIEW",
      ["REPORTS_EDIT", "REPORTS_CREATE", "REPORTS_DELETE", "REPORTS_EXPORT"]
    ]
  },
  "actions": [
    {
      "key": "REPORTS_VIEW",
      "label": "View reports"
    },
    {
      "key": "REPORTS_EDIT",
      "label": "Edit reports",
      "dependencies": ["REPORTS_VIEW"]
    },
    {
      "key": "REPORTS_CREATE",
      "label": "Create reports",
      "dependencies": ["REPORTS_VIEW"]
    },
    {
      "key": "REPORTS_DELETE",
      "label": "Delete reports",
      "dependencies": ["REPORTS_VIEW"]
    },
    {
      "key": "REPORTS_EXPORT",
      "label": "Export reports",
      "dependencies": ["REPORTS_VIEW"]
    }
  ]
}

It wil return a response code 200 and the created entities if all is ok and code 400 otherwise.

Note: This route not requires a authentication but is not accessible outside the kubernetes cluster, so you should run a kubernetes job to register the actions.