@@ -3,32 +3,49 @@ import { AppService } from './app.service';
33import { JwtAuthGuard } from './auth/guards/jwt-auth.guard' ;
44import { RolesGuard } from './auth/guards/roles.guard' ;
55import { Roles } from './auth/decorators/roles.decorator' ;
6+ import { ApiTags , ApiOperation , ApiResponse , ApiBearerAuth } from '@nestjs/swagger' ;
67
8+ @ApiTags ( 'App' )
79@Controller ( )
810export class AppController {
911 constructor ( private readonly appService : AppService ) { }
1012
1113 @Get ( )
14+ @ApiOperation ( { summary : 'Get root hello message' } )
15+ @ApiResponse ( { status : 200 , description : 'Hello message' } )
1216 getHello ( ) : string {
1317 return this . appService . getHello ( ) ;
1418 }
1519
1620 @Get ( 'health' )
21+ @ApiOperation ( { summary : 'Get API health status' } )
22+ @ApiResponse ( { status : 200 , description : 'API health status ok' } )
1723 getHealth ( ) {
1824 return { status : 'ok' } ;
1925 }
2026
2127 @Get ( 'admin-only' )
28+ @ApiBearerAuth ( )
2229 @UseGuards ( JwtAuthGuard , RolesGuard )
2330 @Roles ( 'admin' )
31+ @ApiOperation ( { summary : 'Get secure admin data' } )
32+ @ApiResponse ( { status : 200 , description : 'Admin data retrieved successfully' } )
33+ @ApiResponse ( { status : 401 , description : 'Unauthorized' } )
34+ @ApiResponse ( { status : 403 , description : 'Forbidden (requires admin role)' } )
2435 getAdminData ( ) {
2536 return { role : 'admin' , data : 'secure-data' } ;
2637 }
2738
2839 @Get ( 'editor-only' )
40+ @ApiBearerAuth ( )
2941 @UseGuards ( JwtAuthGuard , RolesGuard )
3042 @Roles ( 'editor' )
43+ @ApiOperation ( { summary : 'Get secure editor data' } )
44+ @ApiResponse ( { status : 200 , description : 'Editor data retrieved successfully' } )
45+ @ApiResponse ( { status : 401 , description : 'Unauthorized' } )
46+ @ApiResponse ( { status : 403 , description : 'Forbidden (requires editor role)' } )
3147 getEditorData ( ) {
3248 return { role : 'editor' , data : 'secure-data' } ;
3349 }
3450}
51+
0 commit comments