Skip to content

Commit

Permalink
✨ Feat: 해당 유저의 태그 조회 API 추가
Browse files Browse the repository at this point in the history
#
  • Loading branch information
ks1ksi committed Aug 10, 2023
1 parent 6cb4140 commit 651542f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tag/tag.controller.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { Controller, UseGuards } from '@nestjs/common';
import { Controller, Get, UseGuards } from '@nestjs/common';
import { TagService } from './tag.service';
import { AuthGuard } from '@nestjs/passport';
import { ApiBearerAuth } from '@nestjs/swagger';
import { GetUid } from '../decorators/get-uid.decorator';

@Controller('tag')
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
export class TagController {
constructor(private readonly tagService: TagService) {}

@Get()
async getTags(@GetUid() uid: string): Promise<string[]> {
return await this.tagService.getTags(uid);
}
}
8 changes: 8 additions & 0 deletions src/tag/tag.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,12 @@ import { PrismaService } from '../prisma/prisma.service';
@Injectable()
export class TagService {
constructor(private readonly prisma: PrismaService) {}

async getTags(uid: string): Promise<string[]> {
const tags = await this.prisma.tag.findMany({
where: { user: { uid } },
});

return tags.map((tag) => tag.name);
}
}

0 comments on commit 651542f

Please sign in to comment.