@gabrythe23/nestjs-custom-decorators
v1.0.1
Published
custom nest decorators for nestjs-custom-decorators
Downloads
1
Readme
Nestjs-custom-decorators
A set of nestjs custom decorators.
Installation
yarn add nestjs-common-custom-decorators
User decorator
A param decorator that fetches the request.user
(could be added by a middleware or a guard) and add it to the params.
Usage:
@Get('/user')
public getUser(@User() user: any): void {
return user;
}
Public endpoint declaration
A param decorator that set isPublic
to true, bypassing the guard
Usage:
@Get('/public-endpoint')
@Public()
public publicEndpoint(): void {
return;
}
Required User Actions
A param decorator that set the required user action for a selected endpoint. Set to requiredActions
.
Usage:
@Get('/user-actions')
@RequiredActions(1,2,3)
public requiredActions(): void {
return;
}
Required User Roles
A param decorator that set the required user roles for a selected endpoint. Set to requiredRoles
.
Usage:
@Get('/user-roles')
@RequiredRoles(1,2,3)
public requiredRoles(): void {
return;
}