entity-routes logo
Docs

Operations#

RouteOperation#

#
typescript
1// Used by @EntityRoute decorator
2// they defines which routes are availables
3type RouteDefaultOperation = "create" | "list" | "details" | "update" | "delete";
4type RouteOperation = RouteDefaultOperation | string;

For basic operations, a RouteOperation defines which RouteController method will be used for a specific route. The basic groups are those that you know well, the CRUD ones.

For custom actions (TODO Link doc), any string can be used to make your own specific route scope.

Example#

#
ts
1@EntityRoute({ path: "/users", operations: ["create", "list"] })
2// ...

GroupsOperation#

#
typescript
1// Used by @Groups decorator
2// they define in which context a property is exposed
3type GroupsOperation = "create" | "list" | "details" | "update" | string;
4type GroupsOperationOrShortcuts = GroupsOperation[] | "all" | "basic";

These are used to define the route scopes where a property might be exposed.

Shortcuts#

There are two shortcuts available for @Groups decorator : "all" and "basic".

  • all litteraly means no matter which operations, the property decorated will be exposed.
  • basic means every basic CRUD_OPERATIONS : [create, list, details, update]

Both shortcuts can be used both on a scoped entity or globally registered for a property.

Example#

#
ts
1// ...
2@Entity()
3class User extends AbstractEntity {
4 @Groups("basic")
5 @Column()
6 name: string;
8 // ...
9}
Global
#
ts
1// ...
2@Entity()
3class User extends AbstractEntity {
4 @Groups({ user: "all", article: ["create", "list"], role: "basic" })
5 @Column()
6 name: string;
8 // ...
9}
Scoped
Prev
Basic usage
Next
Route Scope