@baasi/permission-builder
v1.0.31
Published
Package includes permission converter class
Downloads
116
Readme
Installing
$ npm install
Once the package is installed, you can import the library using import or require approach:
import PermissionBuilder from "@baasi/permission-builder"
Examples
//Example(1) initialize PermissionBuilder using default permission blocks endpoint.
const permissionBuilder = new permissionBuilder();
await permissionBuilder.initPermissions();
//Example(2) initialize permission builder using PermissionBlocks type object.
const permissonBlocks: PermissionBlocks = {
'1': {
meeting_create: 1,
meeting_list: 2,
meeting_info: 4,
meeting_delete: 8
},
'2': {
meeting_stop: 1,
meeting_upgrade: 2,
}
//e.t.c
}
const permissionBuilder = new permissionBuilder(permissonBlocks);
await permissionBuilder.initPermissions();
//Example(3) initialize PermissionBuilder using third party endpoint.
//If you need to use your own endpoint, response data should be in json of the following format.
{
"data": {
"1": {
"meeting_create": 1,
"meeting_list": 2,
"meeting_info": 4,
"meeting_delete": 8
},
"2": {
"meeting_info": 1,
"meeting_upgrade": 2
}
}
}
const permissionBuilder = new permissionBuilder();
const httpOptions: PermissionBuilderOptionsInterface = {
url: 'https://third-party-url.com',
method: 'get',
headers: {"Content-Type": "application/json"}
}
await permissionBuilder.initPermissions(httpOptions);