-
Notifications
You must be signed in to change notification settings - Fork 0
[25.12.17 / TASK-257] Feature - SVG Badge API 추가 #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
ab21edc
1b8086b
ea0407f
ffdc0f0
764ec4b
678e989
131fc22
4fe1504
9e04ad4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { NextFunction, Request, RequestHandler, Response } from "express"; | ||
| import logger from '@/configs/logger.config' | ||
| import { GetSvgBadgeParams, GetSvgBadgeQuery } from "@/types"; | ||
| import { SvgService } from '@/services/svg.service'; | ||
|
|
||
| export class SvgController { | ||
| constructor(private svgService: SvgService) {} | ||
|
|
||
| getSvgBadge: RequestHandler<GetSvgBadgeParams, any, any, GetSvgBadgeQuery> = async ( | ||
|
Check failure on line 9 in src/controllers/svg.controller.ts
|
||
| req: Request<GetSvgBadgeParams, object, object, GetSvgBadgeQuery>, | ||
| res: Response, | ||
| next: NextFunction, | ||
| ) => { | ||
| try { | ||
| const { username } = req.params; | ||
| const { type = 'default'} = req.query; | ||
|
|
||
| const data = await this.svgService.getBadgeData(username, type); | ||
|
|
||
| res.json(data); | ||
| } catch (error) { | ||
| logger.error('SVG Badge 생성 실패: ', error); | ||
| next(error); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import pool from '@/configs/db.config'; | ||
| import express, { Router } from 'express'; | ||
| import { LeaderboardRepository } from '@/repositories/leaderboard.repository'; | ||
| import { SvgService } from '@/services/svg.service'; | ||
| import { SvgController } from '@/controllers/svg.controller'; | ||
| import { validateRequestDto } from '@/middlewares/validation.middleware'; | ||
| import { GetSvgBadgeQueryDto } from '@/types'; | ||
|
|
||
| const router: Router = express.Router(); | ||
|
|
||
| const leaderboardRepository = new LeaderboardRepository(pool); | ||
| const svgService = new SvgService(leaderboardRepository); | ||
| const svgController = new SvgController(svgService); | ||
|
|
||
| /** | ||
| * @swagger | ||
| * /api/{username}/badge: | ||
| * get: | ||
| * summary: 사용자 배지 데이터 조회 | ||
| * tags: | ||
| * - SVG | ||
| * security: [] | ||
| * parameters: | ||
| * - in: path | ||
| * name: username | ||
| * required: true | ||
| * schema: | ||
| * type: string | ||
| * description: 조회할 사용자명 | ||
| * example: ljh3478 | ||
| * - in: query | ||
| * name: type | ||
| * schema: | ||
| * type: string | ||
| * enum: [default, simple] | ||
| * default: default | ||
| * responses: | ||
| * '200': | ||
| * description: 배지 데이터 조회 성공 | ||
| * content: | ||
| * application/json: | ||
| * schema: | ||
| * type: object | ||
| * properties: | ||
| * user: | ||
| * type: object | ||
| * properties: | ||
| * username: | ||
| * type: string | ||
| * totalViews: | ||
| * type: number | ||
| * totalLikes: | ||
| * type: number | ||
| * totalPosts: | ||
| * type: number | ||
| * viewDiff: | ||
| * type: number | ||
| * likeDiff: | ||
| * type: number | ||
| * postDiff: | ||
| * type: number | ||
| * recentPosts: | ||
| * type: array | ||
| * items: | ||
| * type: object | ||
| * '404': | ||
| * description: 사용자를 찾을 수 없음 | ||
| * '500': | ||
| * description: 서버 오류 | ||
| */ | ||
| router.get( | ||
| '/:username/badge', | ||
| validateRequestDto(GetSvgBadgeQueryDto, 'query'), | ||
| svgController.getSvgBadge as any, | ||
|
Check failure on line 74 in src/routes/svg.router.ts
|
||
| ); | ||
Jihyun3478 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| export default router; | ||
Uh oh!
There was an error while loading. Please reload this page.