Replies: 1 comment
-
Hello! As luck would have it, I've been spending some time lately integrating OPA with NestJS, too. The result is this example project, which makes use of the (also new) opa-typescript SDK. I wouldn't go as far as claim that the NestJS integration done there is a "best practice", it's quite basic at this point, but I've been using it as real-world experiment to understand how to make the SDK more usable. Learning from it, we might come up with a higher level package targetting the use of OPA from NestJS. In a gist, this is what it looks like at the moment: @Controller('cats')
@AuthzQuery('cats/allow')
export class CatsController {
constructor(private catsService: CatsService) {}
@Post()
@Authz({ action: 'create', resource: 'cat' })
async create(@Body() createCatDto: CreateCatDto) {
this.catsService.create(createCatDto);
} You're welcome to have a look, and to inform the discussion with your own use case(s)! Feel free to reach out on slack, too 👋 |
Beta Was this translation helpful? Give feedback.
-
Hello Opa community!
I'm excited to share with you a project I'm working on: integrating Opa with a REST API created in NestJS. During my research, I've come across a variety of approaches, but I'd like to tap into the collective experience of this community to identify best practices and optimal approaches.
To kick off the conversation, I'd like to share some of the resources I've been reading:
After this initial research, I've come up with some questions and considerations:
I hope this discussion provides us with the opportunity to share knowledge and collaborate on identifying the best way to integrate Opa with a REST API in NestJS. I look forward to your contributions and experiences!
Beta Was this translation helpful? Give feedback.
All reactions