Skip to content

Commit

Permalink
Merge 34d29c8 into 7df86f3
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Feb 21, 2022
2 parents 7df86f3 + 34d29c8 commit 50138c8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: main
name: Release

on: push

jobs:
Expand Down
4 changes: 2 additions & 2 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"debug": true,
"debug": false,
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand All @@ -19,4 +19,4 @@
],
"@semantic-release/github"
]
}
}
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,56 @@
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/casbin/lobby)

[npm-image]: https://img.shields.io/npm/v/casbin-redis-adapter.svg?style=flat-square

[npm-url]: https://npmjs.org/package/casbin-redis-adapter

[download-image]: https://img.shields.io/npm/dm/casbin-redis-adapter.svg?style=flat-square

[download-url]: https://npmjs.org/package/casbin-redis-adapter

Redis policy storage, implemented as an adapter for [node-casbin](https://github.com/casbin/node-casbin).

Require it in a place, where you are instantiating an enforcer ([read more about enforcer here](https://github.com/casbin/node-casbin#get-started)):
## Installation

```bash
npm install --save casbin-redis-adapter
// or
yarn add casbin-redis-adapter
```

## Usage

Require it in a place, where you are instantiating an
enforcer ([read more about enforcer here](https://github.com/casbin/node-casbin#get-started)):

```typescript

import { newEnforcer } from 'casbin';
import { NodeRedisAdapter }from './adapter' ;
import { join } from 'path';
import {newEnforcer} from 'casbin';
import {NodeRedisAdapter} from './adapter' ;
import {join} from 'path';

const model = join(__dirname, 'casbin_conf/model.conf');
const adapter = await NodeRedisAdapter.newAdapter({host: "127.0.0.1", port: 6379});
const enforcer = await newEnforcer(model, adapter);

const model= join(__dirname, 'casbin_conf/model.conf');
const adapter= await NodeRedisAdapter.newAdapter({host:"127.0.0.1",port:6379});
const enforcer = await newEnforcer(model,adapter);

```
```

That is all what required for integrating the adapter into casbin.

## Configuration

```NodeRedisAdapter.newAdapter()``` takes the following paramters as an object to establish the connection with redis-server
```NodeRedisAdapter.newAdapter()``` takes the following parameters as an object to establish the connection with
redis-server

```typescript
options:
interface IConnectionOptions {
options: interface IConnectionOptions {
host: string // IP address of the Redis server
port: number // Port of the Redis server
}

redisOpts?:
redis.ClientOpts //https://github.com/NodeRedis/node-redis#options-object-properties
redisOpts ? : redis.ClientOpts //https://github.com/NodeRedis/node-redis#options-object-properties
```

## License

[Apache-2.0](./LICENSE)

0 comments on commit 50138c8

Please sign in to comment.