File

src/profile/profile.controller.ts

Prefix

profiles

Index

Methods

Methods

Async follow
follow(email: string, username: string)
Decorators :
@Post(':username/follow')
Parameters :
Name Type Optional
email string No
username string No
Returns : Promise<ProfileRO>
Async getProfile
getProfile(userId: number, username: string)
Decorators :
@Get(':username')
Parameters :
Name Type Optional
userId number No
username string No
Returns : Promise<ProfileRO>
Async unFollow
unFollow(userId: number, username: string)
Decorators :
@Delete(':username/follow')
Parameters :
Name Type Optional
userId number No
username string No
Returns : Promise<ProfileRO>
import { Get, Post, Delete, Param, Controller } from '@nestjs/common';
import { Request } from 'express';
import { ProfileService } from './profile.service';
import { ProfileRO } from './profile.interface';
import { User } from '../user/user.decorator';

import {
  ApiUseTags,
  ApiBearerAuth,
} from '@nestjs/swagger';

@ApiBearerAuth()
@ApiUseTags('profiles')
@Controller('profiles')
export class ProfileController {

  constructor(private readonly profileService: ProfileService) {}

  @Get(':username')
  async getProfile(@User('id') userId: number, @Param('username') username: string): Promise<ProfileRO> {
    return await this.profileService.findProfile(userId, username);
  }

  @Post(':username/follow')
  async follow(@User('email') email: string, @Param('username') username: string): Promise<ProfileRO> {
    return await this.profileService.follow(email, username);
  }

  @Delete(':username/follow')
  async unFollow(@User('id') userId: number,  @Param('username') username: string): Promise<ProfileRO> {
    return await this.profileService.unFollow(userId, username);
  }

}

result-matching ""

    No results matching ""