@@ -6,10 +6,7 @@ import {
66 Param ,
77 Post ,
88 Query ,
9- Req ,
10- Res ,
119} from '@nestjs/common' ;
12- import { Response } from 'express' ;
1310import { CreatePollDto , DeletePollDto , GetPollsDto } from './Poll.dto' ;
1411import { PollService } from './poll.service' ;
1512
@@ -23,28 +20,18 @@ export class PollController {
2320 }
2421
2522 @Get ( )
26- async getPolls (
27- @Req ( ) req ,
28- @Query ( ) query : GetPollsDto ,
29- @Res ( ) res : Response ,
30- ) {
31- const polls = await this . pollService . getPolls ( query ) ;
32- return res . status ( 200 ) . json ( polls ) ;
23+ async getPolls ( @Query ( ) query : GetPollsDto ) {
24+ return await this . pollService . getPolls ( query ) ;
3325 }
3426
3527 @Get ( ':id' )
36- async getPollDetails ( @Param ( 'id' ) id : number , @Res ( ) res : Response ) {
37- const poll = await this . pollService . getPollDetails ( Number ( id ) ) ;
38- return res . status ( 200 ) . json ( poll ) ;
28+ async getPollDetails ( @Param ( 'id' ) id : number ) {
29+ return await this . pollService . getPollDetails ( Number ( id ) ) ;
3930 }
4031
4132 @Delete ( ':id' )
42- async deletePoll (
43- @Param ( 'id' ) id : number ,
44- @Body ( ) query : DeletePollDto ,
45- @Res ( ) res : Response ,
46- ) {
33+ async deletePoll ( @Param ( 'id' ) id : number , @Body ( ) query : DeletePollDto ) {
4734 const poll = await this . pollService . deletePoll ( Number ( id ) , query ) ;
48- return res . status ( 200 ) . json ( { message : 'Poll deleted' , poll : poll } ) ;
35+ return { message : 'Poll deleted' , poll } ;
4936 }
5037}
0 commit comments