@buildery/nest-jwt
v2.0.19
Published
Some useful Nestjs implementations
Downloads
27
Readme
Description
Nestjs implementations for Auth (Bearer: Access Token):
- Decorators
- Guards
- Services
Decorators:
- AccessTokenInfo
async init(@AccessTokenInfo('username') username: string) {
await this.service.run(username);
}
Jwt Service Implementation
Extend JwtTokenService to apply your secret and expiresIn
@Injectable()
export class WorkspaceTokenService extends JwtTokenService {
constructor(private configService: ConfigService) {
super(
configService ? configService.get('JWT_WORKSPACE_TOKEN_SECRET') : process.env.JWT_WORKSPACE_TOKEN_SECRET,
configService ? configService.get('JWT_WORKSPACE_TOKEN_EXPIRESIN') : process.env.JWT_WORKSPACE_TOKEN_EXPIRESIN,
ETokenType.Workspace
);
}
}
Auth Guard implementation:
@Injectable()
export class WorkspaceAuthGuard extends AuthGuard(WorkspaceTokenService){}
Use Auth Guard implementation:
@UseGuards(WorkspaceAuthGuard)
@Controller('permission')
export class PermissionController {
}
Nest framework TypeScript starter repository.
Use
installation
$ npm install @builder/nest-utils