Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Merge develop to master (#25)
Browse files Browse the repository at this point in the history
* update the examples based on change in the config (#22)

* Update README.md (#24)
  • Loading branch information
Nyambati Thomas committed Apr 23, 2016
1 parent de00a7c commit 8eb5173
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,49 +132,51 @@ There are two API methods for express-acl.

**config[type: function, params: path, encoding, baseUrl]**
This methods loads the configuration json file. When this method it looks for `config.json` the root folder if path is not specified.
``` js
var acl = require('express-acl');

// path not specified
// looks for config.json in the root folder
// if your backend routes have base url prefix e.g /api/<resource>, v1/<resource> ,
// developer/v1/<resource>
// specify it in the config property baserUrl {baseurl: 'api'} ,
// {baseurl: 'v1'}, {baseurl: 'developer/v1'} respectively
// else you can specify {baseurl: '/'} or ignore it entirely
``` js
var acl = require('express-acl');

// path not specified
// looks for config.json in the root folder
// if your backend routes have base url prefix e.g /api/<resource>, v1/<resource> ,
// developer/v1/<resource>
// specify it in the config property baserUrl {baseurl: 'api'} ,
// {baseurl: 'v1'}, {baseurl: 'developer/v1'} respectively
// else you can specify {baseurl: '/'} or ignore it entirely


acl.config({
baseUrl:'api'
});
acl.config({
baseUrl:'api'
});

// path specified
// looks for ac.json in the config folder
acl.config({path:'./config/acl.json'});
// path specified
// looks for ac.json in the config folder

acl.config({path:'./config/acl.json'});

// When specifying path you can also rename the json file e.g
// The above file can be acl.json or config.json or any_file_name.json
```
// When specifying path you can also rename the json file e.g
// The above file can be acl.json or config.json or any_file_name.json

```

**getRules[type: function, params: none]** _optional, use it in development environment only_

This enables you to know the rule being applied on a specific user.

```js
// req.decoded.role = 'user'
var currentRule = acl.getRules()
```js
// req.decoded.role = 'user'
var currentRule = acl.getRules()

//current rule will have the rules for user role
```
//current rule will have the rules for user role

```
**authorize [type: middleware]**

This is the middleware that manages your application requests based on the role and acl rules.
This is the middleware that manages your application requests based on the role and acl rules.

```js

app.get(acl.authorize);
```js
app.get(acl.authorize);

```
```
**unless[type:function, params: function or object]**

By default any route that has no defined policy against it is blocked, this means you can not access this route untill you specify a policy. This method enables you to exclude unprotected routes. This method uses express-unless package to achive this functionality. For more details on its usage follow this link [express-unless](https://github.com/jfromaniello/express-unless/blob/master/README.md)
Expand Down

0 comments on commit 8eb5173

Please sign in to comment.