21 lines
571 B
TypeScript
21 lines
571 B
TypeScript
import { Controller, Get, Req, UseGuards } from '@nestjs/common';
|
|
import type { Request } from 'express';
|
|
import { JwtAuthGuard } from './config/auth/jwt-auth.guard';
|
|
import { AppService } from './app.service';
|
|
|
|
@Controller()
|
|
export class AppController {
|
|
constructor(private readonly appService: AppService) {}
|
|
|
|
@Get()
|
|
getHello(): string {
|
|
return this.appService.getHello();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get('protected')
|
|
getProtected(@Req() req: Request): { message: string; user: unknown } {
|
|
return { message: 'authorized', user: req.user };
|
|
}
|
|
}
|