npm.io
1.1.0 • Published 6 years ago

nestjs-custom-decorators-decorators

Licence
ISC
Version
1.1.0
Deps
2
Size
2 kB
Vulns
1
Weekly
0
Stars
247

Nestjs-custom-decorators

A set of nestjs 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;
 }

DecodeJWT

A param decorator that decodes the JSON web token added to the request by a middleware or a guard and add it to the params.

Usage:
 @Get('/decode-jwt')
 public getDecodedJWT(@DecodeJWT() decodedJwt: any): void {
   return decodedJwt;
 }

Keywords