feat: add jwt auth guard and profile endpoint

This commit is contained in:
2026-02-28 08:14:04 +03:30
parent 8212ede785
commit 06f659101d
21 changed files with 371 additions and 31 deletions
@@ -0,0 +1,32 @@
import { IS_PUBLIC_KEY } from '../constants';
import { JwtAuthGuard } from './jwt-auth.guard';
import { ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { Observable } from 'rxjs';
@Injectable()
export class GlobalAuthGuard extends JwtAuthGuard {
constructor(
/**
* Inject Reflector
*/
private readonly reflector: Reflector,
) {
super();
}
canActivate(
context: ExecutionContext,
): boolean | Promise<boolean> | Observable<boolean> {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
context.getHandler(),
context.getClass(),
]);
if (isPublic) {
return true;
}
return super.canActivate(context);
}
}
@@ -0,0 +1,5 @@
import { Injectable } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {}