Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xb4lamx/nestjs-casbin-typeorm
NestJS Casbin module with TypeORM Adapter
https://github.com/0xb4lamx/nestjs-casbin-typeorm
access-control casbin nestjs nestjs-casbin-typeorm typeorm-adapter
Last synced: 3 months ago
JSON representation
NestJS Casbin module with TypeORM Adapter
- Host: GitHub
- URL: https://github.com/0xb4lamx/nestjs-casbin-typeorm
- Owner: 0xb4lamx
- License: mit
- Created: 2020-02-13T16:59:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T20:16:00.000Z (5 months ago)
- Last Synced: 2024-11-01T07:33:22.602Z (3 months ago)
- Topics: access-control, casbin, nestjs, nestjs-casbin-typeorm, typeorm-adapter
- Language: TypeScript
- Size: 1.51 MB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
NestJs Casbin TypeORM
NestJS module for Casbin using the TypeORM Adapter
## Example
In `YOUR_PROJECT_ROOT/src/app.module.ts` file:
```typescript
import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
import { CasbinTypeormModule } from "nestjs-casbin-typeorm";@Module({
imports: [
CasbinTypeormModule.forRootAsync({
imports: [ConfigModule],
inject: [ConfigService],
useFactory: async (configService: ConfigService) => ({
dbConnectionOptions: { // typeORM connectionOptions
type: 'mysql',
host: configService.get('MYSQL_HOST'),
port: configService.get('MYSQL_PORT'),
username: configService.get('MYSQL_USERNAME'),
password: configService.get('MYSQL_PASSWORD'),
database: configService.get('MYSQL_DATABASE'),
},
modelPath: "src/model/roles.conf"
}
)
],
controllers: [AppController],
providers: [AppService]
})
export class AppModule {}
```in `YOUR_PROJECT_ROOT/src/app.service.ts` file:
```typescript
import { Injectable } from "@nestjs/common";
import { CasbinService } from "nestjs-casbin-typeorm";@Injectable()
export class AppService {
constructor(
private readonly casbinService: CasbinService
) {}checkPermission(): boolean {
return this.casbinService.checkPermission("alice", "dataX", "read");
}
}
```## License
This project is [MIT licensed](LICENSE).