Skip to content

OsoClass decorator unclear #432

@weshuiz

Description

@weshuiz

The documentation for the @OsoClass decorator could be explained in more detail. Firstly, how is this decorator used? Nest and Oso need to be aware of its existence, and I assume that classes using the decorator need to be imported. Through trial and error, I figured out that it needs to be provided in the app.module, but nothing was mentioned about this, and I'm not even sure if this is the correct method.

Secondly, registered Oso classes need to have actual values set, which isn't done correctly either. Instead, we get this:

import { OsoClass } from 'nestjs-oso';

@OsoClass()
export class User {
  id: string;
}

Thirdly, the @OsoClass decorator does not allow constructors with a value argument in them, which could have been mentioned, or at least given as a heads up.

Lastly, wouldn't it be nice if a guard were provided instead of expecting us to always write it ourselves?

Sincerely, someone who spent months figuring out these flaws on their own because the documentation was non-existent.

PS: No wonder people prefer Stack Overflow over using official docs (clasic meme)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions